"Switch operation" - Control switch based on a variable

Hi again 🙂

This time I try to reproduce the "Switch operation" event command from RM2K3.

screen.png


This allows to control a switch (Turn OFF/ON), which number is saved in a variable.

For instance, if my variable is = 2, then the Switch number 2 will be turned ON/OFF.

Is it possible to reproduce with MZ ?

Thanks 🙂
Hi there!
Nice suggestion! I will add that into Eli Switches!

NOTE: I just can't believe that RM2K3 have a toggle option and MV/MZ not 😳
Hi there!
Nice suggestion! I will add that into Eli Switches!

NOTE: I just can't believe that RM2K3 have a toggle option and MV/MZ not 😳

Hello, thanks for the answer 🙂
I can't believe it either 😠 I think it's not the only thing that disappeared though 🙁

(I'll give a look at your plugin when it's done 🙂 )
That is a weird omission. However, it's pretty easily reproduced by a script call:
Code:
$gameSwitches.setValue(X, $gameSwitches.value(X) ? false : true);
where both X's are the ID of the switch.
hello,
you are not alone,
i was so frustrated, as i saw, that the rmmz doesnt allow you to connect items with common events ( like for example in the xp version).
had to make a complete new menu (for what i wished), which is still not complete. sorry i dont wanted to spam. but i am still angry about it.
That is a weird omission. However, it's pretty easily reproduced by a script call:
Code:
$gameSwitches.setValue(X, $gameSwitches.value(X) ? false : true);
where both X's are the ID of the switch.
I understood differently, in this case the X would be the variable as in the image.
Something like:
JavaScript:
$gameSwitches.setValue($gameVariables.value(X), true);

Toggle between ON and OFF:
JavaScript:
$gameSwitches.setValue(X, !$gameSwitches.value(X));

Or did I get it wrong?
Code:
$gameSwitches.setValue(X, $gameSwitches.value(X) ? false : true);

I understood differently...
JavaScript:
$gameSwitches.setValue(X, !$gameSwitches.value(X));

Or did I get it wrong?
I'm not sure what you're asking me, those should function identically.
Isn't the request to toggle a switch ID referenced from a value of a certain variable?
Then shouldn't it be like this?

Code:
var v_id = $gameVariables.value(X);
$gameSwitches.setValue(v_id, !$gameSwitches.value(v_id));

If Variable X value is 2, then Switch 2 will be toggled ON/OFF.
@Kuro DCupu That's true - I was focusing on the toggle aspect which doesn't natively exist in MV/Z the way it does in that screenshot.

Replacing the X in any of the code posted above with the script call for a variable's value was just a simple Google away 😉 But you're absolutely right.
@ATT_Turan
I was referring to this option:
Moderator note: @Mr_Petue please do not make posts that have nothing to do with the rest of the thread

Also don't harass other members to give you explanations of why they added a negative reaction to your post. You posted in the wrong place, distracting the conversation that was in progress. That is why they did that. They are not obligated to explain their reasons to you.
I was referring to this option:
Your post confused me because the line of code you gave that would toggle the switch didn't reference the variable...just like mine did not. So they did the same thing.

My brain glossed over the whole variable part of it, as Kuro pointed out 😛
Got it, sorry, it was just an add-on to a more practical way of checking true/false.
Isn't the request to toggle a switch ID referenced from a value of a certain variable?
Then shouldn't it be like this?

Code:
var v_id = $gameVariables.value(X);
$gameSwitches.setValue(v_id, !$gameSwitches.value(v_id));

If Variable X value is 2, then Switch 2 will be toggled ON/OFF.

This works like a charm ! Thanks a lot ! :kiss:
Moderator note: @Mr_Petue please do not make posts that have nothing to do with the rest of the thread

Also don't harass other members to give you explanations of why they added a negative reaction to your post. You posted in the wrong place, distracting the conversation that was in progress. That is why they did that. They are not obligated to explain their reasons to you.
I speak politely to whoever I want. You react way to hard!

edit: I dont "harass" other people. You have come into my live and harass me!

Original thread: https://forums.rpgmakerweb.com/threads/switch-operation-control-switch-based-on-a-variable.140732/