Status
Not open for further replies.

MrKiwi

No Flying Bird
Veteran
Joined
Feb 24, 2019
Messages
175
Reaction score
1,820
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:
 

ThreeSixNine

Veteran
Veteran
Joined
Jan 22, 2019
Messages
511
Reaction score
418
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:

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
525
Reaction score
1,536
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
175
Reaction score
1,820
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!
 

ray_stride07

Veteran
Veteran
Joined
Feb 28, 2022
Messages
56
Reaction score
10
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.

View attachment 141738

Is this what you are trying to achieve?

Is this will work ?
 

Attachments

  • Captursdae.PNG
    Captursdae.PNG
    16.8 KB · Views: 6

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,196
Reaction score
10,906
First Language
Czech
Primarily Uses
RMMV
In Javascript and most other programming languages = is assignment and that's why it doesn't work. If you want to compare, use ==
 

ray_stride07

Veteran
Veteran
Joined
Feb 28, 2022
Messages
56
Reaction score
10
First Language
Indonesia
Primarily Uses
RMMV
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 <= ?
 

Poryg

Dark Lord of the Castle of Javascreeps
Veteran
Joined
Mar 23, 2017
Messages
4,196
Reaction score
10,906
First Language
Czech
Primarily Uses
RMMV
< is less than and <= is less than or equal to.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,924
Reaction score
2,982
First Language
EN
Primarily Uses
RMMZ

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.

 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Sometimes I wonder why I still try and recruit others to help with my games. It never works.
ScreenShot_10_3_2022_4_27_17.png
welp, thanks to Luna MV, I was able to add the Balloon as a window... thus allowing me to edit the font color and outline... so now it looks like comic bubbles above characters. I have NO idea why I couldn't get this to work through more conventional means, but here we are.
CUTE CUTE CUTE.gif
I cannot cease doing cute art
War and Wonder is a 100% choice-based open-world visual novel.
1664821313732.png
1664821466359.png
1664821547746.png
Going live soon on Twitch, and will continue Fortunastreet's game "Verloren". For those who are curious, you are welcome to join ;)

-> Franz' Twitch channel

Forum statistics

Threads
125,749
Messages
1,173,225
Members
164,911
Latest member
KyzerKiba
Top