MV Need help with conditional passive state code

I'm trying to create a passive state that will go away when one of two different states are applied.
Code:
<Custom Passive Condition>
  if (user.isStateAffected(54)) {
    condition = false;
  } else {
    if (user.isStateAffected(83)) {
      condition = false;
    } else {
      condition = true;
    }
</Custom Passive Condition>
and I'm getting an error message. Can anyone tell me what I'm doing wrong?
You're missing a curly brace at the end
You could also try to structure it like this (untested):
JavaScript:
if (!(user.isStateAffected(54) || user.isStateAffected(83))) {
    condition = true;
} else {
    condition = false;
)

// alternatively

if (user.isStateAffected(54) || user.isStateAffected(83)) {
    condition = false;
} else {
    condition = true;
)
You could also get rid of the trues and falses. Any time you're just going off the result of a conditional, they're unnecessary. So you could simply do:
Code:
<Custom Passive Condition>
condition = !user.isStateAffected(54) && !user.isStateAffected(83);
</Custom Passive Condition>
Yeah, I wasn't sure if Yanfly's passive states allowed that (I only know VisuStella's does), but that'd be a better way of doing it.
@Navas You won't find JavaScript that's somehow different depending on a plugin - code is code. They can absolutely differ in terms of whether they give you, say, a target variable to reference or stuff like that...but JS syntax is always the same.
You could also get rid of the trues and falses. Any time you're just going off the result of a conditional, they're unnecessary. So you could simply do:
Code:
<Custom Passive Condition>
condition = !user.isStateAffected(54) && !user.isStateAffected(83);
</Custom Passive Condition>
thanks! this works well.
@Navas You won't find JavaScript that's somehow different depending on a plugin - code is code. They can absolutely differ in terms of whether they give you, say, a target variable to reference or stuff like that...but JS syntax is always the same.
But one is MV and one is MZ. That could actually make a difference. Dont know in which cases it is different, but not all code should automatically work on both engines, or am I wrong here? (Total javascript noob)

Yeah, I wasn't sure if Yanfly's passive states allowed that (I only know VisuStella's does), but that'd be a better way of doing it.
When you think something could work, but you're not sure, just test it out and see.

Of course you are free to ask for help, I dont mean to say you shouldn't, but if you try anything you think has the tiniest chance of working, and it works (maybe at the second or third try) you will be more likely to understand the solution and more importantly, to remember the solution.

I know not all devs would agree, but in my point of view asking is good, experimenting is great. But maybe that is just a personal preference.
But one is MV and one is MZ. That could actually make a difference. Dont know in which cases it is different, but not all code should automatically work on both engines, or am I wrong here? (Total javascript noob)


When you think something could work, but you're not sure, just test it out and see.

Of course you are free to ask for help, I dont mean to say you shouldn't, but if you try anything you think has the tiniest chance of working, and it works (maybe at the second or third try) you will be more likely to understand the solution and more importantly, to remember the solution.

I know not all devs would agree, but in my point of view asking is good, experimenting is great. But maybe that is just a personal preference.
For the *most* part, anything dealing with game objects should translate verbatim between the engines. The main differences are in image caching and how windows work.
But one is MV and one is MZ. That could actually make a difference. Dont know in which cases it is different, but not all code should automatically work on both engines, or am I wrong here? (Total javascript noob)
If the Javascript code is referencing a RPG Maker-specific object or function defined differently in MV compared to MZ in the core files it would matter. Most of the issues of code incompatibility between the two versions involve windows or saving.
I remember that when I moved my project to MZ from MV, I didn't know what const/let did (and some script calls/plugins have minor differences) so that's probably why I thought Yanfly's passives' syntax might not 100% equal VisuStella's.
Most of the issues of code incompatibility between the two versions involve windows or saving.
Okay. I didn't know that, to be honest. I knew there were changes (after all with no changes, it would be the same engine, right?) I just didn't know what the changes were.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-conditional-passive-state-code.159992/