Hello community,
sry for wrong words if I use them. English is not my first language.
I have a problem with addition and subtration of numbers to a variable.
I used SetGlobalVariable to add 1 to a ressource called "money".
I created the variable before in an extra script.
SetGlobalVariable
money
8
then I added 1 to it by button press.
so object created with left pressed event and put
SetGlobalVariable
global.money
global.money+1
It works fine. As intended.
But now my problem.
I have in another room a second button which shall decrease money.
therefore I put the same in this button but -4 instead of +1
SetGlobalVariable
global.money
global.money-4
I get the sum: -278 ?? why
I tried to write the same as above again.
global.money+1
and I get the sum: 68
How can this happen? Where is this way too much value of 60 coming from? There are only these two buttons which change the global variable.
Note: The second buttons is placed inside another object and gets created by a different button.
to explain it simple. I click a region on my map and a popup with a button in it appears.
I dont know if this has something to do with this?
Much thanks for reading and hopefully helping.
sry for wrong words if I use them. English is not my first language.
I have a problem with addition and subtration of numbers to a variable.
I used SetGlobalVariable to add 1 to a ressource called "money".
I created the variable before in an extra script.
SetGlobalVariable
money
8
then I added 1 to it by button press.
so object created with left pressed event and put
SetGlobalVariable
global.money
global.money+1
It works fine. As intended.
But now my problem.
I have in another room a second button which shall decrease money.
therefore I put the same in this button but -4 instead of +1
SetGlobalVariable
global.money
global.money-4
I get the sum: -278 ?? why
I tried to write the same as above again.
global.money+1
and I get the sum: 68
How can this happen? Where is this way too much value of 60 coming from? There are only these two buttons which change the global variable.
Note: The second buttons is placed inside another object and gets created by a different button.
to explain it simple. I click a region on my map and a popup with a button in it appears.
I dont know if this has something to do with this?
Much thanks for reading and hopefully helping.
Last edited: