Jory4001

Regular
Regular
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,911
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

Regular
Regular
Joined
Mar 5, 2013
Messages
39,926
Reaction score
11,873
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

Regular
Regular
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,911
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

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,153
Reaction score
16,971
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 Posts

Latest Profile Posts

Time for the next chance for y'all to affect my advent calendar! Where should Day 7's sprite come from: land, sea, or demon realm? :rwink:
Throné's final boss is weird. He is a guy holding a baby while fighting off attackers. I think his name was Santos. I might be thinking of someone else.
I think I've just about finished fighting the fight with the tileset I was most intimidated by for game jam. No pictures yet, the map isn't presentable, but I think the tileset will work! I'm very relieved XD
Twitch! At it again with more gamedev for a couple hours, followed by some Valheim with my friend. Feel free to drop by~
these 80+ gb updates on several years old games are the absolute worst. I just want to play for an hour or so before bed to unwind. Sorry, gotta spend that time downloading an update. Then my mods will be broken so I'll have to start over or wait for those to be updated to. Is a complete game within three years of the pay to be a beta tester period really to much to ask?

Forum statistics

Threads
136,782
Messages
1,269,873
Members
180,523
Latest member
Reimu
Top