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

#1 2007-05-24 14:17:22

DigiRaver
Scratcher
Registered: 2007-05-23
Posts: 3

Negative variables?

Hello...I'd like to lower the value of one variable based on the value of another variable.  What I have seen so far Scratch offers the command 'Change variablename by ...' but this seems to only increment the value...I want to decrement.  Make sense?  How would I go about this?

Thanks for your time...

Offline

 

#2 2007-05-24 14:22:02

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Negative variables?

Change variable by -10

or

set variable to variable - 10

both work.

Offline

 

#3 2007-05-24 14:23:08

weissjd
Scratcher
Registered: 2007-05-16
Posts: 64

Re: Negative variables?

You can multiply the variable you want to decrement by by (-1). Something like this:

Change Var1 by (var2 * -1)

Offline

 

#4 2007-05-24 14:25:44

DigiRaver
Scratcher
Registered: 2007-05-23
Posts: 3

Re: Negative variables?

Wow...I need to go back to math class.  Anyway, thank you weissjd...that is EXACTLY what I was looking for!!!   wink

njoy!

Offline

 

#5 2007-05-24 14:32:47

Roberth
Scratcher
Registered: 2007-05-15
Posts: 46

Re: Negative variables?

You can also do this:

"Set Var1 to Var1 - Var2"

You don't have to get real fancy here and do multiplication.

Offline

 

#6 2007-05-24 14:39:54

DigiRaver
Scratcher
Registered: 2007-05-23
Posts: 3

Re: Negative variables?

haha...I forgot there is the 'set Var' command as well as the 'change Var to' command.  Well, still learning  wink  but thanks!

Offline

 

Board footer