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

#1 2010-06-29 21:40:11

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

How to Make a Negative Number

Hi, I have an AI project, which I've just updated. I wanted to add the abillity to decrease and increase attack, so I created it. However, there was a problem. The Script, is basically If touching enemy and enemy costume equals attack, Change health by -1. So, I added a variable there, but I can't make a negative variable! If anyone knows how, please tell me, so the attack can be changed. Thanks! (here's a link to the project if you want to see it) http://scratch.mit.edu/projects/DrVonKitty/1161086


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#2 2010-06-29 21:44:53

12three
Scratcher
Registered: 2008-06-12
Posts: 1000+

Re: How to Make a Negative Number

I'll take a look.  smile

Offline

 

#3 2010-06-29 21:48:56

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to Make a Negative Number

Hm... Variables should by default be allowed to go into the positive and negative... Is there something you've done to limit this?

Offline

 

#4 2010-06-30 09:37:27

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

Well, you see, the block has a DIFFERENT variable, with the plain variable in there. I'll show you.

[blocks]<change{ai health}by( <{ attack }>[/blocks]


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#5 2010-06-30 09:39:46

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

That turned out as a miserable block. Well, you get the point still?


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#6 2010-06-30 09:42:54

MaxtheWeirdo
Scratcher
Registered: 2010-03-18
Posts: 500+

Re: How to Make a Negative Number

positive * negative = negative
negative * negative = postive

That should help.


My website. Hall Crawler My Awesome OS
It's just marketing, guys! Nothing sinister!

Offline

 

#7 2010-06-30 09:49:09

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

I know that math, but I don't know how that would make that negative. I need the Attack to be negative. If you can explain a little further, that would be nice.


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#8 2010-06-30 09:54:41

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

wait... could [0-attack] work?


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#9 2010-06-30 10:35:09

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to Make a Negative Number

DrVonKitty wrote:

wait... could [0-attack] work?

Yes, you can either use "0 - attack" or "attack * -1" and it should work just fine.

Hope that helps!

Paddle2See made a comment earlier that it might be milliseconds faster to do a subtraction than a multiplication. He didn't seem too sure about it, though.

I commonly use "attack * -1."

Offline

 

#10 2010-06-30 10:51:55

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

Okay, I'll try that. I'll get to work on a V3 for my game now! Thanks guys!


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

#11 2010-06-30 11:02:37

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How to Make a Negative Number

DrVonKitty wrote:

Okay, I'll try that. I'll get to work on a V3 for my game now! Thanks guys!

No problem! Glad things are working out for you  smile

Offline

 

#12 2010-06-30 11:57:52

DrVonKitty
Scratcher
Registered: 2010-02-16
Posts: 11

Re: How to Make a Negative Number

All right! V3 is out!


View The Adventures of Scratch the Cat!
http://scratch.mit.edu/projects/DrVonKitty/1222616

Offline

 

Board footer