MZ (SOLVED) Question about variables

While scripting an event, I define at the begining a variable, a number comprised between 1 and 15.
Then, several times during the event, I call a conditional branch using this variable.

Question : does the variable stay the same from the very first time I define it, or does it change every time I call for it in a conditional branch ?
The value is only set in the "control variables" command; its value remains the same when you check it in a conditional branch.
The variable would only change if the event loops and it runs the set variable command again. Or if you change it again in some other event of course.
Just to clarify on what @Trihan and @SGHarlekin said - because you're saying you're "scripting" an event, and you're "defining" a variable, are you using a game variable? Or something you defined in a script call?

If you're doing a Script event command and saying something like
Code:
let my_thing = 10

a separate Script command (or Conditional Branch) will have no idea what my_thing is, it's gone as soon as your Script command is done.

If you are using a game variable (either via Control Variables or referencing $gameVariables in a Script command), then the above is all correct.
The variable would only change if the event loops and it runs the set variable command again. Or if you change it again in some other event of course.
The variable would only change if the event loops and it runs the set variable command again. Or if you change it again in some other event of course.

Just to clarify on what @Trihan and @SGHarlekin said - because you're saying you're "scripting" an event, and you're "defining" a variable, are you using a game variable? Or something you defined in a script call?

If you're doing a Script event command and saying something like
Code:
let my_thing = 10

a separate Script command (or Conditional Branch) will have no idea what my_thing is, it's gone as soon as your Script command is done.

If you are using a game variable (either via Control Variables or referencing $gameVariables in a Script command), then the above is all correct.

Thank you for your answers !

So to be clear, if I'm using this variable (1-15) as a dice throw of sorts, I should re-define it (control variable command) before any new conditional branch if I want this variable number to be different for every conditional branch I'm calling during that same event ?
Of course. A variable can't change its value if you don't tell it to.
Of course. A variable can't change its value if you don't tell it to.
I naively thought that the engine might consider a variable number to be always variable, and thus always re-defined when called upon through a conditional branch.
Anyway, thank you, it's perfectly clear now !
I naively thought that the engine might consider a variable number to be always variable, and thus always re-defined when called upon through a conditional branch.
Anyway, thank you, it's perfectly clear now !
Variable just means it *can* change as opposed to being a static immutable constant, but it won't do any value changes you don't specifically request.

Original thread: https://forums.rpgmakerweb.com/threads/solved-question-about-variables.183866/