Jory4001

Veteran
Veteran
Joined
Feb 16, 2014
Messages
80
Reaction score
20
First Language
English
I have an event with a conditional that needs the "Script" so it can check multiple things at once, If (A < C) && (A > D) Then...


I tried:


$gameVariables.(26) > 60 && $gameVariables(26) < 81;


but I get a syntax error "("


I am fairly familiar with javascript conditionals and have do many in my plugins, but I'm not sure how the "Script" event handles them...
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,870
First Language
English
Primarily Uses
RMVXA
$gameVariables.value(26) > 60 && $gameVariables.value(26) < 81 is the correct syntax.


Don't forget you can also nest Conditional Branches within each other (place the < 81 check inside the block that runs if it's > 60) - in this case, this approach would save you from needing to remember JS syntax (though there are things you might need to check like a troop member's current TP that would require a scripted condition).
 
Last edited by a moderator:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
35,900
Reaction score
9,518
First Language
German
Primarily Uses
RMMV
the script option is javascript, but you used the wrong names. Check the forum for the correct function names to get the values of the variables.


Additionally, the syntax error in that form was caused by the point before the (
 

Jory4001

Veteran
Veteran
Joined
Feb 16, 2014
Messages
80
Reaction score
20
First Language
English
Thanks, I knew about nesting the Conditionals, but that is very inefficient!


the .value was what I was missing! I Checked the forums and google and found nothing, I also checked the script call equivalent page and it only showed how to set a variable.


Thanks for the Help!
 

Wavelength

MSD Strong
Global Mod
Joined
Jul 22, 2014
Messages
6,114
Reaction score
5,870
First Language
English
Primarily Uses
RMVXA
You're welcome!


What I've done to figure out the correct syntax when unsure (which is 80% of the time, lol) is to open up the game's scripts (accessible from the game's 'js' folder) and search for words that I think might be useful, such as "variables".  Sometimes you need to luck upon the right word, or search through a lot of irrelevant results, but eventually you'll usually find a good example of how to use the syntax you need. :)
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,718
Reaction score
15,847
First Language
English
Primarily Uses
RMMV
the Game_Interpreter class within the rpg_objects.js file is a good one.  If you can do it through an event command, that section of code will show the js behind that command.  You'll learn a whole lot by studying the Game_Interpreter functions.
 

Latest Threads

Latest Profile Posts

1653529725808.png
>Wake up in the night
>Can't sleep
>Draw little freak
>Come up with pancake based puns for attacks
>Back to bed
UHHHHH. What is this and how did someone find my game on here? 1653527395160.png
ScreenShot_5_25_2022_7_37_13.png

my game has distinct areas where travel through what are known as "battle stations" these are more or less areas to explore and fight. occasionally, you'll stumble across secret rooms with sidequests ready to be taken. this area is in the high school attic of all places... but how do ya get there is the question.
Redoing my intro scene for the 10 millionth time is pain
So this flat Earther named Mike Hughes build his own rocket to prove that the Earth was flat. But on liftoff he still had the ladder he climbed up to the rocket laying against it. Needless to say things didn't go as planned.

Forum statistics

Threads
122,125
Messages
1,146,704
Members
160,411
Latest member
WillianAxe
Top