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

#1 2011-09-07 15:26:42

zippolulu
Scratcher
Registered: 2010-05-04
Posts: 9

variables

I have used variables for my game. When character walking over lava the health will go down with -1 but the meter continue to count down as long as the character stands on the lava spot. How do I just get -1 point when touching lava. The same with health it goes up up until I move away from it. I used the example from the stage monitor (last ex)
http://wiki.scratch.mit.edu/wiki/Tutorial_About_Variables
THanks.

Offline

 

#2 2011-09-07 17:11:23

slammer111
New Scratcher
Registered: 2011-09-01
Posts: 33

Re: variables

zippolulu wrote:

I have used variables for my game. When character walking over lava the health will go down with -1 but the meter continue to count down as long as the character stands on the lava spot. How do I just get -1 point when touching lava. The same with health it goes up up until I move away from it. I used the example from the stage monitor (last ex)
http://wiki.scratch.mit.edu/wiki/Tutorial_About_Variables
THanks.

i probably am wrong (seeing how i dont know much about what i am talking about) but in theory, would one of those stop buttons work, in the motion tab? put it in the forever block, and it might just stop that script, until you trigger the lava again.

Offline

 

#3 2011-09-07 17:15:20

slammer111
New Scratcher
Registered: 2011-09-01
Posts: 33

Re: variables

slammer111 wrote:

zippolulu wrote:

I have used variables for my game. When character walking over lava the health will go down with -1 but the meter continue to count down as long as the character stands on the lava spot. How do I just get -1 point when touching lava. The same with health it goes up up until I move away from it. I used the example from the stage monitor (last ex)
http://wiki.scratch.mit.edu/wiki/Tutorial_About_Variables
THanks.

i probably am wrong (seeing how i dont know much about what i am talking about) but in theory, would one of those stop buttons work, in the motion tab? put it in the forever block, and it might just stop that script, until you trigger the lava again.

sry, control tab, not motion

Offline

 

#4 2011-09-07 20:16:49

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: variables

To keep it from continually reducing your health, you should tell the script to wait until it's no longer touching the lava, like this:

Code:

if <touching color red>
    change health by -1
    wait until <not touching color red>

(Just remember that this script needs to be separate from the one for movement, otherwise it will freeze once you touch lava.)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#5 2011-09-09 08:44:38

zippolulu
Scratcher
Registered: 2010-05-04
Posts: 9

Re: variables

Fantastic. Thanks a lot.!!!

Offline

 

Board footer