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

#1 2012-12-18 13:20:14

finlayvscott
New Scratcher
Registered: 2012-12-05
Posts: 14

What's wrong with this script?

How can I fix this?

It's a game a lot like storm the house, but I can't get the guy to die on click using health variables. What's wrong?

Here's the script (I tried to do the whole scratchblocks things but me and it doesn't get along):


when gf clicked
switch to costume <costume1>
hide variable <health>
set <health> to <10>


when sprite1 clicked
change health by <pick random <-5> to <-10>

when gf clicked
if <<health>=<0>>
switch to costume<costume3>
wait <0.5> secs
switch to costume<costume4>
wait <0.5> secs
switch to costume<costume5>
wait <0.5> secs
switch to costume<costume6>

thanks!

Offline

 

#2 2012-12-18 13:27:47

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: What's wrong with this script?

when gf clicked
switch to costume <costume1>
hide variable <health>
set <health> to <10>


when sprite1 clicked
change health by <pick random <-5> to <-10>

when gf clicked
if <<health>=<0>>
switch to costume<costume3>
wait <0.5> secs
switch to costume<costume4>
wait <0.5> secs
switch to costume<costume5>
wait <0.5> secs
switch to costume<costume6>
(Just doing this so I can see it a little better.)


6418,

Offline

 

#3 2012-12-18 13:30:18

letmethink
Scratcher
Registered: 2010-05-09
Posts: 100+

Re: What's wrong with this script?

it should be forever if health = 0 not just if health =0


Clicky Clicky!!!               I am writing a book...             Look here

Offline

 

#4 2012-12-18 13:34:54

CheeseMunchy
Scratcher
Registered: 2008-10-13
Posts: 1000+

Re: What's wrong with this script?

What you need is a "forever if"... And I would recommend that you put a "stop script" at the bottom of the forever if, if you aren't going to use the script anymore. But if you are using it again, don't.

when gf clicked
forever if <(health)=[0]>
switch to costume[costume3]
wait [0.5] secs
switch to costume[costume4]
wait [0.5] secs
switch to costume[costume5]
wait [0.5] secs
switch to costume[costume6]
stop script

Last edited by CheeseMunchy (2012-12-18 13:36:02)


6418,

Offline

 

#5 2012-12-18 13:52:05

finlayvscott
New Scratcher
Registered: 2012-12-05
Posts: 14

Re: What's wrong with this script?

actually I've fixed it now thanks! But I'll get back to you if I encounter any more problems...

Offline

 

#6 2012-12-18 14:07:26

finlayvscott
New Scratcher
Registered: 2012-12-05
Posts: 14

Re: What's wrong with this script?

Laugh if you want, I have a new problem.

How would I make it so that if a character was moving, then got killed, it wouldn't keep moving to the house?

Offline

 

#7 2012-12-18 14:30:31

finlayvscott
New Scratcher
Registered: 2012-12-05
Posts: 14

Re: What's wrong with this script?

Also, I need this for pause and day complete features, so please respond!

Offline

 

#8 2012-12-18 18:48:13

mrn0body
Scratcher
Registered: 2012-12-11
Posts: 37

Re: What's wrong with this script?

put this for your moving script instead

when gf clicked
forever
if < key [right arrow] pressed and not health = 0 >
change x by [5]
end


Why Fit In When You Were Born To Stand Out

Offline

 

#9 2012-12-18 18:51:27

mrn0body
Scratcher
Registered: 2012-12-11
Posts: 37

Re: What's wrong with this script?

sorry you would use the and, not and = blocks instead of that whole block


Why Fit In When You Were Born To Stand Out

Offline

 

Board footer