Status
Not open for further replies.

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
Hello lovely people!

I'm using bottom script below to trigger a game message and turning on a switch if that switch is off.

However, I'm getting the game message when the switch is on as well, so I must be doing something wrong with the JS.

1610771496497.png
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,274
Reaction score
14,274
First Language
English
Primarily Uses
RMMV
You have an OR and an AND in the same condition, so it will be evaluated from left to right - if variable 1 is 12, it won't check the other things.

If you want variable 1 to be 12 or 13 AND switch 23 is off, put parentheses around the two variable checks:

Code:
if (($gameVariables.value(1) == 12 || $gameVariables.value(1) == 13) && !$gameSwitches.value(23)) {
  do stuff
}

Though you could have done all of that using event commands anyway
 

Rixxus

Veteran
Veteran
Joined
Oct 23, 2020
Messages
45
Reaction score
8
First Language
English
Primarily Uses
RMMZ
You have an OR and an AND in the same condition, so it will be evaluated from left to right - if variable 1 is 12, it won't check the other things.

If you want variable 1 to be 12 or 13 AND switch 23 is off, put parentheses around the two variable checks:

Code:
if (($gameVariables.value(1) == 12 || $gameVariables.value(1) == 13) && !$gameSwitches.value(23)) {
  do stuff
}

Though you could have done all of that using event commands anyway
Oh yeah!
Thanks @Shaz!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,274
Reaction score
14,274
First Language
English
Primarily Uses
RMMV

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 Posts

Latest Profile Posts

Finished reworking the design of my Itch.io page <3 Back to making plugins.
I kind of want make a map that's just giant version of the player that's they're running around on. Either by stringing together multiple maps or just by shrinking the player sprite for those maps. Actually that might make a fun reveal... The player's on a normal looking map, but then as realization dawns on them it zooms out to show a much larger map that's a giant version of the player. :LZSexcite:
Do you like to practice level design? I do hahahaha! It's not from a specific game, it's just some tests...Fase 1.png
I really need a better indicator of where you can jump up and down though I feel... otherwise I like how this turned out for the first part of the first dungeon of the game.
@Shaz needs to make a website for his plugins. (it can be done easily for free with google sites.) I can't find a database of them anywhere!

Forum statistics

Threads
109,130
Messages
1,042,399
Members
141,628
Latest member
Ocarina654
Top