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

#1 2011-08-11 20:14:48

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

variable problem

in my project when you kill all the zombies the variable keeps going up and I dont know why the link to my projects is http://scratch.mit.edu/projects/4lover/1973370 and if you could download it and tell me whats wrong it would be appreciated


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#2 2011-08-11 21:32:05

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: variable problem

with what i saw it appears you just set the veriable it doest seem you told it when to increase


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#3 2011-08-11 21:34:55

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: variable problem

Well i said that when one of the zombies dies it broadcasts a code and when the variable recieves the code it increases by one but instead when I kill a zombie it keeps increasing forever


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#4 2011-08-11 22:07:39

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: variable problem

4lover wrote:

Well i said that when one of the zombies dies it broadcasts a code and when the variable recieves the code it increases by one but instead when I kill a zombie it keeps increasing forever

Try doing this:

When I Recieve whatever
forever
set variable to variable + 1
stop script

I don't know if it'll work though...


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#5 2011-08-11 22:13:35

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: variable problem

nope it doesnt work


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#6 2011-08-11 22:18:55

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

Re: variable problem

Thescratch3 wrote:

4lover wrote:

Well i said that when one of the zombies dies it broadcasts a code and when the variable recieves the code it increases by one but instead when I kill a zombie it keeps increasing forever

Try doing this:

When I Recieve whatever
forever
set variable to variable + 1
stop script

I don't know if it'll work though...

That will just stop that script. Evidently the message is being broadcast over and over again, so you should look at yours scripts to make sure there's nothing that will keep looping and sending it out.  hmm

For example, you may have a script that sends a message when it's touching something, like this:

Code:

When green flag clicked
forever if <touching sprite2>
    broadcast [message]

This will cause the variable to increase rapidly because as long as it's touching the sprite, it will send the message repeatedly. You can fix this by modifying the script like this:

Code:

When green flag clicked
forever if <touching sprite2>
    broadcast [message] and wait
    wait until not <touching sprite2>

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

 

#7 2011-08-11 23:13:54

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: variable problem

nope it still doesnt work I think you guys miht be able to find the probelem if you look at my project here:http://scratch.mit.edu/projects/4lover/1973370


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#8 2011-08-11 23:40:29

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: variable problem

hmm try getting rid of the brodcastand set it up like this i think it might work
when sprite touches sprite increase deaths by 1 wait untill not touching sprite


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

#9 2011-08-12 00:13:20

4lover
Scratcher
Registered: 2010-04-24
Posts: 500+

Re: variable problem

how do you make the not touching sprite part?


Check out this awesome new zombie-cod type of game: http://scratch.mit.edu/projects/4lover/1975649

Offline

 

#10 2011-08-12 00:31:51

slayerrobe7
Scratcher
Registered: 2011-06-24
Posts: 500+

Re: variable problem

under operator thier not and under sencing is touching


!!!When it comes to Scratch2.0 I am totally like freaking out!!!

Offline

 

Board footer