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

#1 2007-07-31 12:09:45

kiteflyer
Scratcher
Registered: 2007-07-30
Posts: 16

Restrictions?

How can I make it so when a variable goes to 0 a feature stops?
Thx
Joe (Kiteflyer)


92% of teens have moved on to rap.
If you are part of the 8% who still listen to real music, copy and paste this into your signature

Offline

 

#2 2007-07-31 12:48:27

natalie
Scratch Team
Registered: 2007-03-07
Posts: 100+

Re: Restrictions?

Hi Joe, It depends on how you have programmed the feature.

A couple possibilities:

"repeat until variable < 1"
...

or

(for something that's already in a forever loop or triggered often):
if variable < 1
   stop script

Would one of those work for what you're doing?

(Note: I suggested "variable < 1" rather than "variable = 0" just in case the variable goes below 0 before the code gets a chance to check it)

Offline

 

#3 2007-07-31 12:52:04

kiteflyer
Scratcher
Registered: 2007-07-30
Posts: 16

Re: Restrictions?

The features are health and ammo. I shall trie this out later. THX
Joe (Kiteflyer)


92% of teens have moved on to rap.
If you are part of the 8% who still listen to real music, copy and paste this into your signature

Offline

 

#4 2007-07-31 12:58:56

natalie
Scratch Team
Registered: 2007-03-07
Posts: 100+

Re: Restrictions?

Oh, here's an easier way if you just want the variable itself to not go any lower than 0...
you can check before you subtract anything from the variable. (e.g., health)

"if health > 1
  change health by -1"

(so it won't go below 0).

Offline

 

Board footer