Odd/Even number checks.

Hi everyone, I'm having a little difficulty with variables and need some more input.

I'll sum up what I'm trying to achieve:
I have an event that runs a looping cycle such as (Default, A, B, Default, A, B etc etc...)

But on page A I have a value of 1 added to a variable to indicate a cycle of 1, and a conditional branch that's meant to check if that variable is an odd or even number which both give different results, so when the page cycles through A again it should result an even number and then odd on the 3rd cycle, so on and so forth.
Now in order to have these checks made I have to run the conditional check through a modulo operation but I'm getting pretty confused with the sequences in which happens. When I think I got it correct after the next few cycles it looks like one of the outcomes seems to always take domination. I don't understand what I am doing wrong:
adaddadad.png


I'm after an arithmetic sequence like 1,2,1,2,1,2. How can I achieve this?
youd want your modulo operation to happen either before the check and save the result to run on your conditional statement, or have the modulo itself be the conditional statement.
also a %2 can only return 1 or 0. checking if the value is not equal to 2 would mean that its always going to pass

you can use another variable and set it equal to your variable 150, do %2 on that, and then have your conditional use that variable's value, but id just use "$gameVariables.value(150)%2==0" myself as the condition
JavaScript:
// Put this in a script conditional check
$gameVariables.value(150) % 2 === 0 // Check even
$gameVariables.value(150) % 2 === 1 // Check odd

EDIT: I Was too slow, oof
Before I resort to the script call checks are you saying that the page should be set up like this?

◆Control Variables:#0150 SV: A += 1
◆Control Variables:#0150 SV: A %= 0
◆Comment:Rotation is an Even #
◆If:Script:$gameVariables.value(150) % 2 === 0 // Check even
◆Play SE:Objective (90, 100, 0)
◆Text:None, None, Window, Bottom
:Text:EVEN
:Text:\SV[150, 0, 0]
◆Control Switches:#0104 → InnerTurn = ON
◆
:Else
◆Comment:Rotation is an Odd #
◆Play SE:Cancel1 (90, 100, 0)
◆Text:None, None, Window, Bottom
:Text:ODD
:Text:\SV[150, 0, 0]
◆Control Switches:#0104 → InnerTurn = OFF
◆
:End
◆Common Event:Traffic Light Timer
◆Control Self Switch:B = ON

Sorry been away for a drive so im trying to play catch up.
You don't need this line:
Code:
◆Control Variables:#0150 SV: A %= 0
If you are already using this line:
Code:
◆If:Script:$gameVariables.value(150) % 2 === 0

Also i would remove the "// Check even" from the condition script, just in case.
Before I resort to the script call checks are you saying that the page should be set up like this?
As TobyYasha said, you dont need to perform the variable operations at all if youre already using the script. Having that second line there doesnt accomplish anything of value here. itll make sure that that variable can only be 0 or 1, but the script skips the step of needing to set that value in the first place.

Also wasnt sure if you needed to keep the value of that variable around. if its only used here to check for an even/odd iteration and you werent using the script, then its no big deal, but if you needed to use the number total iterations, or do another modulo operation on the number of iterations down the line, it would overwrite it.
For some strange reason the script method doesn't seem to work, it always throws it into the even number outcome despite the changes here, but the method including the introduction of a new variable i.e "Flask count" to check the value of "Hall Tokens" as given by the example seems to work it nicely enough.

Just curious and I am bracing myself for any kind of error, but variables seem to only amount to a maximum of 99999999 in value, when that number reaches that maximum the outcome will always be the odd number, I don't quite know how well MZ operates having to reach such a high number but if I wanted to control it so that it resets to the beginning instance at some point, what measures should I take?

Also i'm not the greatest with formulas, but what would Variable 2 (Flask Token) = Variable 1 (Hall Token) formula look like? I'm trying to experiment with Hakuen Studio's Self Variables plugin.
For some strange reason the script method doesn't seem to work, it always throws it into the even
if you found a solution in the extra variable, then thats good, but mind sharing how the script version was set up?

also i mentioned that the line i spoke about wouldnt do anything, but i didnt notice that it was "A %= 0" and not "A %= 2". in that case, it would set that variable to be NaN because you cant divide by a 0 and a modulo requires a division. when the game tries to check that value with that function, itll use 0 instead. so if that line stayed there, that modulo would always result in even number. But that only matters if you kept that line

Just curious and I am bracing myself for any kind of error
The editor imposes that limitation, but that isnt a game limitation afaik. Variable values ingame should be able to go up to somewhere about 1.7 e+308 (2^1024). but if you anticipate that value going above that point, you could make it so that if it hits some arbitrary value, the event sets the variable back to 0.

EDIT:
Also i'm not the greatest with formulas, but what would Variable 2 (Flask Token) = Variable 1 (Hall Token) formula look like? I'm trying to experiment with Hakuen Studio's Self Variables plugin.
The script for that? would be "$gameVariables.setValue(2, $gameVariables.value(1))"
The script version I used was:

Code:
◆Control Variables:#0150 SV: A += 1
◆Control Variables:#0150 SV: A %= 0
◆Comment:Rotation is an Even  #
◆If:Script:$gameVariables.value(150) % 2 === 0
 ◆Play SE:Objective (90, 100, 0)
 ◆Text:None, None, Window, Bottom
 :Text:EVEN
 :Text:\SV[150, 0, 0]
 ◆Control Switches:#0104 → InnerTurn = ON
 ◆
:Else
 ◆Comment:Rotation is an Odd  #
 ◆Play SE:Cancel1 (90, 100, 0)
 ◆Text:None, None, Window, Bottom
 :Text:ODD
 :Text:\SV[150, 0, 0]
 ◆Control Switches:#0104 → InnerTurn = OFF
 ◆
:End
◆Common Event:Traffic Light Timer
◆Control Self Switch:B = ON

As for the self variable formula, I'm not 100% certain it's working due to the nature of the plugin already having an operation window:
The script version I used was:
its exactly as i had thought then
also i mentioned that the line i spoke about wouldnt do anything, but i didnt notice that it was "A %= 0" and not "A %= 2". in that case, it would set that variable to be NaN because you cant divide by a 0 and a modulo requires a division. when the game tries to check that value with that function, itll use 0 instead. so if that line stayed there, that modulo would always result in even number. But that only matters if you kept that line
that second line forces the value of A % 2 to only ever be zero. it had to be removed

As for the self variable formula, I'm not 100% certain it's working due to the nature of the plugin already having an operation window:
oh. thats what you meant by formula. im not familiar with that plugin, but try using set as your operation and $gameVariables.value(1) as your value
Been spending quite alot of time examining the possibilities and it looks like I got it working to how I've been wanting it.
So for the time being i'll be conducting further tests, if you're curious this is what the page looks like.

◆Plugin Command:Eli/EliMZ_SelfVariables, Control Self Variables
:Plugin Command:Map Id = 0
:Plugin Command:Event Id = 0
:Plugin Command:Self Var id = 150
:Plugin Command:Operation Type = Add
:Plugin Command:Value = 1
◆Plugin Command:Eli/EliMZ_SelfVariables, Control Self Variables
:Plugin Command:Map Id = 0
:Plugin Command:Event Id = 0
:Plugin Command:Self Var id = 150
:Plugin Command:Operation Type = Mod
:Plugin Command:Value = 2
◆If:SV: A = 0
◆Comment:Rotation is an Even #
◆Play SE:Objective (90, 100, 0)
◆Plugin Command:Eli/EliMZ_SelfVariables, Control Self Variables
:Plugin Command:Map Id = 0
:Plugin Command:Event Id = 0
:Plugin Command:Self Var id = 150
:Plugin Command:Operation Type = Set
:Plugin Command:Value = 0
◆Control Switches:#0104 → InnerTurn = ON
◆
:Else
◆Comment:Rotation is an Odd #
◆Play SE:Cancel1 (90, 100, 0)
◆Control Switches:#0104 → InnerTurn = OFF
◆
:End
◆Common Event:Traffic Light Red/Green
◆Control Self Switch:B = ON

Original thread: https://forums.rpgmakerweb.com/threads/odd-even-number-checks.166379/