Discuss Scratch

Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Hello, recently thanks to a user named Cutie_Pooge i resolved an issue i had. This leads to another problem i have. I want to make a system in where whenever a variable “Multiplier” changes by 1, the variable “Score” increases the score income by 1 if this makes sense. To clarify, whenever the Multiplier increases by 1, every time you click the sprite, the Score increases by 1 more then before. (eg. my multiplier is 2 and ill earn 3 score per point). Ill put a code in an image as its less time consuming.

https://imgur.com/a/5z8DeN2

EDIT: ISSUE HAS BEEN RESOLVED

Last edited by Phantom_User (July 17, 2020 14:33:27)

Oumuamua
Scratcher
1000+ posts

How can i make it so upon a variable change another variable changes (confusing)

Assuming that you set "Multipier to zero under the green flag, you substitute change Score by 1 with change Score by (Multiplier+1)
That in case i don`t missunderstood your.
Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Oumuamua wrote:

Assuming that you set "Multipier to zero under the green flag, you substitute change Score by 1 with change Score by (Multiplier+1)
That in case i don`t missunderstood your.
Do you mind telling me how do i substitute the score? I cant figure it out…
Oumuamua
Scratcher
1000+ posts

How can i make it so upon a variable change another variable changes (confusing)


Phantom_User wrote:

Oumuamua wrote:

Assuming that you set "Multipier to zero under the green flag, you substitute change Score by 1 with change Score by (Multiplier+1)
That in case i don`t missunderstood your.
Do you mind telling me how do i substitute the score? I cant figure it out…

when green flag clicked
set Score to (0)
when this sprite clicked
change Score by (Multiplier+1)
… here the other blocks…
Cutie_Pooge
Scratcher
500+ posts

How can i make it so upon a variable change another variable changes (confusing)

I see a problem with the code, multiplier changes when the code is divisible by 10 with no remainder. If the score is, say 78 and you change it by 3 you get 81 and multiplier doesn't increase. However, there's a simple solution that fixes this with no multiplier variable.
when this sprite clicked
change [Score v] by (([floor v] of ((Score) / (10))) + (1))
Hopefully, it works again as I usually don't test scripts.

Last edited by Cutie_Pooge (July 16, 2020 17:23:16)

Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Cutie_Pooge wrote:

I see a problem with the code, multiplier changes when the code is divisible by 10 with no remainder. If the score is, say 78 and you change it by 3 you get 81 and multiplier doesn't increase. However, there's a simple solution that fixes this with no multiplier variable.
when this sprite clicked
change [Score v] by (([floor v] of ((Score) / (10))) + (1))
Hopefully, it works again as I usually don't test scripts.
Thanks for the attempt to help, this sadly doesnt work, it starts of at 1 and then goes to 2.1->3.3->4.6->6->7.6…
It also doesnt change the multiplier when i pass 10
Oumuamua
Scratcher
1000+ posts

How can i make it so upon a variable change another variable changes (confusing)

May be this is not exactly following your specifications, but i think it is a good alternative, you just try it

Last edited by Oumuamua (July 17, 2020 00:01:05)

Cutie_Pooge
Scratcher
500+ posts

How can i make it so upon a variable change another variable changes (confusing)

Oumuamua wrote:

May be this is not exactly following your specifications, but i think it is a good alternative, you just try it

~snip
As I explained in my earlier comment, that would not work.

Phantom_User wrote:

Thanks for the attempt to help, this sadly doesnt work, it starts of at 1 and then goes to 2.1->3.3->4.6->6->7.6…
It also doesnt change the multiplier when i pass 10
I tried out the script it does work. I have also identified where you went wrong with the script.
You used
((([floor v] of (Score)) / (10)) + (1))
but it should be
(([floor v] of ((Score) / (10))) + (1))
The score must be divided before floored, you floored it before dividing it.

Last edited by Cutie_Pooge (July 17, 2020 03:08:02)

Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Cutie_Pooge wrote:

Oumuamua wrote:

May be this is not exactly following your specifications, but i think it is a good alternative, you just try it

~snip
As I explained in my earlier comment, that would not work.

Phantom_User wrote:

Thanks for the attempt to help, this sadly doesnt work, it starts of at 1 and then goes to 2.1->3.3->4.6->6->7.6…
It also doesnt change the multiplier when i pass 10
I tried out the script it does work. I have also identified where you went wrong with the script.
You used
((([floor v] of (Score)) / (10)) + (1))
but it should be
(([floor v] of ((Score) / (10))) + (1))
The score must be divided before floored, you floored it before dividing it.
Thanks again, this seems to work however the Multiplier variable doesnt change digits when i go over 10 , i havent changed the code of the Multiplier 0“digit changer” from original URL (https://imgur.com/a/5z8DeN2) Ive tried “Score mod 100 / 100 = 0” and it doesnt work (this was one of the only ideas i thought might work). Do you have any idea on how to fix this? The current code is https://imgur.com/a/qUTyqeB (edit: i set everything to 100 for testing purposes)

Last edited by Phantom_User (July 17, 2020 09:09:46)

Oumuamua
Scratcher
1000+ posts

How can i make it so upon a variable change another variable changes (confusing)

This by @Cutie_Pooge seems to work

Cutie_Pooge wrote:

…snip…

Phantom_User wrote:

Thanks for the attempt to help, this sadly doesnt work, it starts of at 1 and then goes to 2.1->3.3->4.6->6->7.6…
It also doesnt change the multiplier when i pass 10
I tried out the script it does work. I have also identified where you went wrong with the script.
You used
((([floor v] of (Score)) / (10)) + (1))
but it should be
(([floor v] of ((Score) / (10))) + (1))
The score must be divided before floored, you floored it before dividing it.
OpenUI
New Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Hai there! You seem to have resolved the issue in order to keep the forums in good condition I will be asking this to be closed as from what I can see you have sorted it, once again thanks for everyones help in resolving this users issue and best of luck with whatever you are creating!
Oumuamua
Scratcher
1000+ posts

How can i make it so upon a variable change another variable changes (confusing)

OpenUI wrote:

Hai there! You seem to have resolved the issue in order to keep the forums in good condition I will be asking this to be closed as from what I can see you have sorted it, once again thanks for everyones help in resolving this users issue and best of luck with whatever you are creating!

May be this guy has further questions.
Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

OpenUI wrote:

Hai there! You seem to have resolved the issue in order to keep the forums in good condition I will be asking this to be closed as from what I can see you have sorted it, once again thanks for everyones help in resolving this users issue and best of luck with whatever you are creating!
I will close it but how should i even trust that you are a moderator or someone with higher privilages as it clearly says “New to scratch” with only 8 posts?
Cutie_Pooge
Scratcher
500+ posts

How can i make it so upon a variable change another variable changes (confusing)

I do not completely understand what you mean. You know longer need the multiplier variable but if you still want it you just use this code:
set [Multiplier v] to (([floor v] of ((Score) / (10))) + (1))
But again, the multiplier variable is obsolete for changing the score variable but you can still use
change [Score v] by (Multiplier)
if you want to use the Multiplier variable.

Phantom_User wrote:

I will close it but how should i even trust that you are a moderator or someone with higher privilages as it clearly says “New to scratch” with only 8 posts?
They aren't a moderator, but they can still report your post to be closed which is what we usually do.
Phantom_User
Scratcher
8 posts

How can i make it so upon a variable change another variable changes (confusing)

Cutie_Pooge wrote:

I do not completely understand what you mean. You know longer need the multiplier variable but if you still want it you just use this code:
set [Multiplier v] to (([floor v] of ((Score) / (10))) + (1))
But again, the multiplier variable is obsolete for changing the score variable but you can still use
change [Score v] by (Multiplier)
if you want to use the Multiplier variable.

Phantom_User wrote:

I will close it but how should i even trust that you are a moderator or someone with higher privilages as it clearly says “New to scratch” with only 8 posts?
They aren't a moderator, but they can still report your post to be closed which is what we usually do.
I just published one of the games that was made possible by the forums - I dont need any more help, however thanks for helping regardless. As for the closing the post I dont know how to close it so I just edited it.

Powered by DjangoBB