Variables script call help!

MrKiwi

No Flying Bird
Veteran
Joined
Feb 24, 2019
Messages
115
Reaction score
507
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
146
Reaction score
128
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

Raze: The Rakuen Zero's Guardian!
Veteran
Joined
May 22, 2018
Messages
1,358
Reaction score
605
First Language
Portuguese - Br
Primarily Uses
RMMV
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
434
Reaction score
1,383
First Language
Bahasa
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
115
Reaction score
507
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!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Brioche with a crème patissiere filling is so tasty!
A group of Game creators and others who trying to revive the Feel of Multiplayer and TOWN/ROLEPLAY games
Wow, lots of RPG Maker MV stuff on sale on Steam for 50%-75% off. Steam, why you not tell me?!
looking for help on top secret project
The nick "Toeuia" that I'm using comes from a, idk, you okay the chess game while chit chatting them. The first two are students. Then you know, finally, the champion, and then the champion's sensei. I played like this so many times until suddenly there's another chess master. Very naive but super smart. After he lost, he kinda advised me not to give up on chest. Because the next one was never seen beaten. Touya.

Forum statistics

Threads
99,383
Messages
964,655
Members
131,002
Latest member
SaltedFish
Top