Discuss Scratch

storytb
New Scratcher
1 post

If Statement for when Variable reaches 0 - How do I make one?

I have a game where a spaceship has a shield of 100 and goes through a maze and I want it to blow up when/ “if” the shield gets to 0.

https://scratch.mit.edu/projects/58133472/#player

How do I make the variable or sensor of when the score hits 0 that the costume changes?

Thanks,
Tom
Birdlegs
Scratcher
1000+ posts

If Statement for when Variable reaches 0 - How do I make one?

ifshield< 1thenswitchcostumeto blamkapowboom

This is probably better, as it has padding in case the variable goes below zero :3
deck26
Scratcher
1000+ posts

If Statement for when Variable reaches 0 - How do I make one?

Rather than a forever loop checking the value and not actually doing anything else useful you could use

waituntilvariable< 0.1

followed by what you want to happen.
zacadoole1
Scratcher
100+ posts

If Statement for when Variable reaches 0 - How do I make one?

whenclickedwaituntilvariable<1 broadcastblow upwhenclickedforeverifvariable<1 thenbroadcastblow up

The first one only works once, but the second one will keep working if you have another script change the variable to something higher than 0 right away.

Last edited by zacadoole1 (April 21, 2015 22:42:17)

cs520522
Scratcher
2 posts

If Statement for when Variable reaches 0 - How do I make one?

-frostyiceprincess-
Scratcher
1000+ posts

If Statement for when Variable reaches 0 - How do I make one?

cs520522 wrote:

Please do not spam or necropost.
VOVEX
Scratcher
1 post

If Statement for when Variable reaches 0 - How do I make one?

Thank you for helping me. This helped me on my project so much!!
NightSpark23
New Scratcher
1 post

If Statement for when Variable reaches 0 - How do I make one?

hi
deck26
Scratcher
1000+ posts

If Statement for when Variable reaches 0 - How do I make one?

VOVEX wrote:

Thank you for helping me. This helped me on my project so much!!
There's no need to thank people when it makes the topic move back to the top of the forum.

NightSpark23 wrote:

hi
Please don't spam.
Bautista990
Scratcher
2 posts

If Statement for when Variable reaches 0 - How do I make one?

thanks soooooooooooooooooooooooooooo much
Bautista990
Scratcher
2 posts

If Statement for when Variable reaches 0 - How do I make one?

its was alot of help
deck26
Scratcher
1000+ posts

If Statement for when Variable reaches 0 - How do I make one?

Bautista990 wrote:

its was alot of help
Still not necessary to necropost to say that though.

Powered by DjangoBB