Discuss Scratch

GoonsNCSU
New Scratcher
2 posts

Increasing Level Every Time Score Increases by 10

I accidentally necroposted on someone else's thread (I apologize, not great for my first post here!) but was wondering if someone could help with the following:

I'd like my variable ‘level’ to increase by 1 every time my variable ‘score’ increases by 10. I've tried if score = 10 then change level by 1….but I know I can't do this in a forever loop.

Any thoughts?

Thanks so much!
asivi
Scratcher
1000+ posts

Increasing Level Every Time Score Increases by 10

Hi, you can use the mod block so at the moment you increase score

changescoreby1ifscoremod10=0thenchangelevelby1
totalcode
Scratcher
9 posts

Increasing Level Every Time Score Increases by 10

whenclickedforeversetrequirementtolevel*10ifscore=requirementthenchange levelby1

this should work
deck26
Scratcher
1000+ posts

Increasing Level Every Time Score Increases by 10

If the score only changes in one place checking it as @asivi says is the best method.

If the score may change in multiple places you'll need a separate loop but avoid unnecessarily resetting a variable as @totalcode shows.

In the case of a separate check I'd do

foreverwaituntilscore>level*10-1changelevelby1anyothercoderequiredtochangelevel
You could use equals rather than greater than if you know score only ever changes by 1 but the above is generally safer.
asivi
Scratcher
1000+ posts

Increasing Level Every Time Score Increases by 10

Well, in case you change score in multiple places as @deck26 commented you can have the script with the mod in just one place(no need of repeating it) and call it by bradcasting a message when it changes, so you can avoid race conditions that come up in case you change score very quickly and the project would be too busy(laggy perhaps).
PCookie_
Scratcher
4 posts

Increasing Level Every Time Score Increases by 10

In my case, whenever the score increases by 10, I want my “coin” sprite to appear on the screen. I just don't know how to manage that.
Morimop
Scratcher
1000+ posts

Increasing Level Every Time Score Increases by 10

PCookie_ wrote:

In my case, whenever the score increases by 10, I want my “coin” sprite to appear on the screen. I just don't know how to manage that.
Hello there! Sorry, but… You are necroposting.

Scratch Wiki wrote:

If the topic has been inactive for a significant length of time, and the new post adds nothing to the topic, then the post can be considered a necropost. However, a post in a sticky or ITopic is not considered a necropost if it adds more useful information (these topics are kept at the top of the forum page anyway, so posting does not bump them). Necroposting on purpose is strongly discouraged, as it is unhelpful, clogging up the top of the forum with outdated and unneeded topics.
PCookie_
Scratcher
4 posts

Increasing Level Every Time Score Increases by 10

totalcode wrote:

whenclickedforeversetrequirementtolevel*10ifscore=requirementthenchange levelby1

this should work

what does requirement mean?
codeman1044
Scratcher
1000+ posts

Increasing Level Every Time Score Increases by 10

Please don't necropost. If you need help with something, then please create your own topic.
arkanSkibbidob
Scratcher
1 post

Increasing Level Every Time Score Increases by 10

I am tyring to make a project
this is it
https://scratch.mit.edu/projects/896950552/editor

Im trying to shrink the code pls help
existentialcrisises
Scratcher
100+ posts

Increasing Level Every Time Score Increases by 10

As Morimop and codeman1044 said, please don't necropost. This topic is around 6 years old. If you want to ask a question about your project, please create a new topic.

Powered by DjangoBB