Variables script call help!

MrKiwi

No Flying Bird
Veteran
Joined
Feb 24, 2019
Messages
167
Reaction score
1,138
First Language
Spanish
Primarily Uses
RMMV
Hey there! I'm not very good with script calls, I barely understand them... :kaosigh:

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 :kaopride:
 

xDRAGOONx

Veteran
Veteran
Joined
Jan 22, 2019
Messages
240
Reaction score
196
First Language
English
Primarily Uses
RMMV
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)
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,776
Reaction score
1,197
First Language
Portuguese - Br
Primarily Uses
RMMZ
You can try use this:

if($gamePlayer.y === ($gameMap.event(ID).y - 1)){
do your code.
};
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
480
Reaction score
1,470
First Language
Indonesia
Primarily Uses
RMMV
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?
 
Last edited:

MrKiwi

No Flying Bird
Veteran
Joined
Feb 24, 2019
Messages
167
Reaction score
1,138
First Language
Spanish
Primarily Uses
RMMV
Thanks y'all for the help, specially the differences between the equals signs ^-^

It works now, so, problem solved!
 

Latest Threads

Latest Profile Posts

Is this Profile Banner thing new? Or did I just discovered it now?
Well.. I was going to post my randomly generated road experiments... But the new "Attach Files" on profile posts seems to be quite buggy. Also there's no more option to insert Imgur images. Highly unfortunate. Guess I'll give them a bit to fix it and go back to messing with stuff.
my first day back to working on my project and i'm pooped!! hope to get back in the rhythm soon!

Forum statistics

Threads
107,595
Messages
1,030,826
Members
139,701
Latest member
beccokiwis
Top