This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-03-01 19:44:02

rocklover122
New Scratcher
Registered: 2013-03-01
Posts: 6

Simple Variables. I need help

I'm trying to make it so every second 10 will be added to the variable score. What's wrong?

When the player is dead, the variable dead will equal 0

when player clicked
forever
if <(dead) = [1]>
   wait [1] secs
   change [score] by [10]
else
   stop script
Please help

Offline

 

#2 2013-03-01 19:47:22

rocklover122
New Scratcher
Registered: 2013-03-01
Posts: 6

Re: Simple Variables. I need help

also, clicking the player sets dead to be 1. (brings them to life)

Offline

 

#3 2013-03-01 20:21:08

rocklover122
New Scratcher
Registered: 2013-03-01
Posts: 6

Re: Simple Variables. I need help

Never mind. I saved closed and reopened the project and now it is working fine. If you have any idea why it wasn't working, I would appreciate them info. I didn't change anything.

Offline

 

#4 2013-03-02 00:24:12

Teleport
Scratcher
Registered: 2013-02-28
Posts: 33

Re: Simple Variables. I need help

I can answer your first question.

when gf clicked
set score to 0
when gf clicked
forever if <(score) < [100]>
  wait [1] secs
  change (score) by [10]
end
What this script means is that:
When the flag is clicked, the score will be set to 0.
If the score is less than 100(100 is the maximum amount), it will follow this routine UNTIL it reaches 100:
wait 1 sec
add score by 10

If you're using this for a game, credit would be appreciated. ;D


http://i38.tinypic.com/j9q2s8.png

Offline

 

#5 2013-03-02 00:27:53

Teleport
Scratcher
Registered: 2013-02-28
Posts: 33

Re: Simple Variables. I need help

You can always change the maximum amount. It doesn't have to always be 100.


http://i38.tinypic.com/j9q2s8.png

Offline

 

#6 2013-03-02 11:16:17

rocklover122
New Scratcher
Registered: 2013-03-01
Posts: 6

Re: Simple Variables. I need help

Teleport wrote:

I can answer your first question.

when gf clicked
set score to 0
when gf clicked
forever if <(score) < [100]>
  wait [1] secs
  change (score) by [10]
end
What this script means is that:
When the flag is clicked, the score will be set to 0.
If the score is less than 100(100 is the maximum amount), it will follow this routine UNTIL it reaches 100:
wait 1 sec
add score by 10

If you're using this for a game, credit would be appreciated. ;D

I don't want a maximum amount though. and I figured it out. All i had to do was remove the "stop script" block.

Offline

 

Board footer