Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » something about making minimum score be 0
- coolkid4917
- Scratcher
3 posts
something about making minimum score be 0
is anyone able to tell me how to make a score meter not go into a negative (-) and always stay at 0 once reached? I have a game called cat clicker, but I need a little bit of help with the score not going down more than 0.
If i figure it out before someone answers, I'll just delete this topic
If i figure it out before someone answers, I'll just delete this topic
Last edited by coolkid4917 (March 31, 2024 05:22:12)
- Platinum_02
- Scratcher
6 posts
something about making minimum score be 0
forever
if <(SCORE) < [0]> then
set [SCORE v] to [0]
I hope this helps
- deck26
- Scratcher
1000+ posts
something about making minimum score be 0
But rather than a forever loop just check the score whenever you change it - if the score is less than the amount you're about to subtract set it to 0 instead. An extra forever loop should not be required and could run earlier in the frame than the actual change meaning you could still see a negative value (eg forever loop sets value to 0, other script subtracts 1, frame is redrawn with value = -1, repeat).
- Platinum_02
- Scratcher
6 posts
something about making minimum score be 0
Oh, really? Thank you for telling me more about scratch, I'll keep that in mind But rather than a forever loop just check the score whenever you change it - if the score is less than the amount you're about to subtract set it to 0 instead. An extra forever loop should not be required and could run earlier in the frame than the actual change meaning you could still see a negative value (eg forever loop sets value to 0, other script subtracts 1, frame is redrawn with value = -1, repeat).
- --Irrelevant
- Scratcher
90 posts
something about making minimum score be 0
forever
if <(SCORE) < [0]> then
set [SCORE v] to [0]
I hope this helps
And if you want the minimum score to be something else - other than 0, then use this script:
if <(SCORE) < (Minimum)> then
set (SCORE) to (Minimum)
end
I'm Irrelevant! (jk)
What I'm good at:
Creating evil kumquats
Creating more evil kumquats
Creating even more evil kumquats because why not?
GIMME YOUR FOLLOW
My profile…
- Wolf_Link21
- Scratcher
100+ posts
something about making minimum score be 0
if it's for a shop you could have something like this
when this sprite clicked
if <<(money) >(price)>> then
change [money v] by ((0) - (price))
change [item v] by (1)
end
This is dave
:D :: hat :: motionHe protects my from evil kumquats.
Please follow me if you find my response helpful and give me any ideas for my game https://scratch.mit.edu/projects/992371983/
- deck26
- Scratcher
1000+ posts
something about making minimum score be 0
No, that only allows you to buy if you have more than enough money and not if you have the exact amount. if it's for a shop you could have something like thiswhen this sprite clicked
if <<(money) >(price)>> then
change [money v] by ((0) - (price))
change [item v] by (1)
end
- coolkid4917
- Scratcher
3 posts
something about making minimum score be 0
Ok, maybe i can update cat clicker! With the thing!
- Discussion Forums
- » Help with Scripts
- » something about making minimum score be 0