- Joined
- Oct 30, 2015
- Messages
- 18
- Reaction score
- 5
- First Language
- English
What would be the correct way to do this then? How do I associate a game variable with a string? How do I then call said game variable using the $gameMessage function?The script box is build like a "sandbox" programming - closing a scriptbox deletes everything assoziated with it. So the next script box has no access to older variables, no matter what they are.
You can only store data in variables that had been defined outside the script command (by a plugin, or in the game variables)
But what if one wanted to reference that variable in another script command instead for the purposes of conditional branches? What would the code for that look like?You could set one of MV's variables like this (MV itself will only let you store numbers in them, but in a script you are free to do otherwise):
$gameVariables.setValue(1, "text");
This will store the string "text" in variable #1.
In your message, you can then use \V[1] to retrieve that value.
That game variable are the ones contained in the editor, so think of them as something of a global scope. @Chronic Heart
This means
$gameVariables.setValue(1, "text");
Sets the game variable at id 1 in the editor to some string, which you can reference anywhere -- even in another script command for example.