Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Adding Two Control Variables Together

MinisterJay

Administrator
Staff member
Administrator
I am making a game that has gold used as points. Level 1 is easy, as the points are exactly what the score is, and this is stored as control variable [0001]. After that the gold is zeroed out. At the end of level 2, the new gold is stored as control variable [0002]. I saw something online that showed that to add the two control variable, putting control variable [0003] as $game_variables[1]+$game_variables[2], within script . Maybe I did something wrong because this has not worked.

Any suggestions on how to add two control variables together?
 

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
I am making a game that has gold used as points. Level 1 is easy, as the points are exactly what the score is, and this is stored as control variable [0001]. After that the gold is zeroed out. At the end of level 2, the new gold is stored as control variable [0002]. I saw something online that showed that to add the two control variable, putting control variable [0003] as $game_variables[1]+$game_variables[2], within script . Maybe I did something wrong because this has not worked.

Any suggestions on how to add two control variables together?
Not at home right now; Just from memory i believe it is this...
JavaScript:
$gameVariables.setValue(3, $gameVariables.value(1) + $gameVariables.value(2));
Also typed on a phone (sorry if there are typo's).

Let me know if that does the trick. (cool)
 
Last edited:

MinisterJay

Administrator
Staff member
Administrator
ControlVariables.png

When it comes to the \V[3] points, in the dialogue, it comes up with a 0. Did I input it the wrong way possibly?
 

CT_Bolt

Global Moderator
Staff member
Resource Team
Xy$
0.02
I tried that earlier too. It might be the type of variable I am using.
Oh lol I just realised you're using the event command (not the script command) to set the variable... the way I original gave you is all script.

To use the way you have above would just be:
$gameVariables.value(1) + $gameVariables.value(2)
 
Last edited:

MinisterJay

Administrator
Staff member
Administrator
Thanks. Will test in morning.
[doublepost=1508817929,1508816954][/doublepost]Thanks a bunch. That was the solution!
 
Top