Variables script call help!

Hey there! I'm not very good with script calls, I barely understand them... 😔

I feel like what I'm trying to pull out is kinda easy, but its not working for me. Basically I want to use a script for a conditional branch where I want it to run if the player Y position is 1 tile above an event Y position.

I'm trying this script: if $gameVariables.value(3) = $gameVariables.value(5) - 1

But... nothing actually happens when I test it, as I said, I don't know much about this, anyone knows what's my mistake? (Probably everything) I'll be grateful if you lend me a hand 😤
What exactly are you trying to achieve?
-EDIT, I did not read the part about player position and event position...
Here's an example of an if statement using a variable expression:

if ($gameVariables.value(111) < 11) {
$gameVariables.setValue(101, $gameVariables.value(101) + 100)
}

So if game variable 111 is less than 11, add 100 to the value of game variable 101.

the expression after 'if' needs to be contained in parenthesis '( )'

Also, try '==' as opposed to just '=';
'==' is a logic operator meaning 'equal'
while
'=' is an assignment operator that assigns the value of the right operand to the left operand.

Try:
if ($gameVariables.value(3) == $gameVariables.value(5) - 1)
You can try use this:

if($gamePlayer.y === ($gameMap.event(ID).y - 1)){
do your code.
};
Script for conditional branch?
Then you should have use double equal.
= Single equal mean you are assigning a value to that variable.
== Double equal mean you are doing a comparison, expecting a true / false outcome.
=== Triple equal is the same as double equal, but much stricter.

1588313822290.png


Is this what you are trying to achieve?
Thanks y'all for the help, specially the differences between the equals signs ^-^

It works now, so, problem solved!
Script for conditional branch?
Then you should have use double equal.
= Single equal mean you are assigning a value to that variable.
== Double equal mean you are doing a comparison, expecting a true / false outcome.
=== Triple equal is the same as double equal, but much stricter.

View attachment 141738

Is this what you are trying to achieve?

Is this will work ?
In Javascript and most other programming languages = is assignment and that's why it doesn't work. If you want to compare, use ==
In Javascript and most other programming languages = is assignment and that's why it doesn't work. If you want to compare, use ==

If i use > and < it will work ? or i have to use >= and <= ?
< is less than and <= is less than or equal to.
< is less than and <= is less than or equal to.
Oh okey thank you my friend.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/variables-script-call-help.120932/