Reputation: 19
Im making a cookie clicker game and i have cookie per click upgrades, there is a cost that starts at 50,000 cookies then everytime you buy it, it multipies by 100. But when i put the cost variable into any statement the value changes to 0 for somereason, why?
If i buy an upgrade the cost turns into 0, because of the problem explained above. But when i take the cost variable out of the statement, it goes back to 50,000, why?
Upvotes: 0
Views: 89
Reputation: 59
This is because you cannot put separation characters in variables if you want your variable to be a pure number.
If your variable is 50000 (let's call this var1
), and you add a comma to it so it becomes 50,000 (call this var2
) Scratch will treat the var2
as not a numerical value!
And so Scratch will handle this by just evaluating 50,000 * 100
to 0.
Upvotes: 1