"Switch operation" - Control switch based on a variable

Luth

Veteran
Veteran
Joined
Apr 29, 2014
Messages
148
Reaction score
69
First Language
French
Primarily Uses
RMMZ
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 :)
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
2,220
Reaction score
1,717
First Language
Portuguese - Br
Primarily Uses
RMMZ
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 o_O
 

Luth

Veteran
Veteran
Joined
Apr 29, 2014
Messages
148
Reaction score
69
First Language
French
Primarily Uses
RMMZ
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 o_O

Hello, thanks for the answer :)
I can't believe it either :mad: I think it's not the only thing that disappeared though :(

(I'll give a look at your plugin when it's done :) )
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,141
Reaction score
1,147
First Language
English
Primarily Uses
RMMV
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.
 

Mr_Petue

Villager
Member
Joined
Sep 24, 2021
Messages
5
Reaction score
1
First Language
german
Primarily Uses
RMMZ
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.
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
861
Reaction score
433
First Language
PT-BR
Primarily Uses
RM2k3
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?
 

Kuro DCupu

Trust me, I'm a veteran RMer
Veteran
Joined
Jul 6, 2014
Messages
525
Reaction score
1,528
First Language
Indonesia
Primarily Uses
RMMV
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.
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,141
Reaction score
1,147
First Language
English
Primarily Uses
RMMV
@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 :wink: But you're absolutely right.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
43,649
Reaction score
15,280
First Language
English
Primarily Uses
RMMV

@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.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
2,141
Reaction score
1,147
First Language
English
Primarily Uses
RMMV
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 :stickytongue:
 

Dev_With_Coffee

Veteran
Veteran
Joined
Jul 20, 2020
Messages
861
Reaction score
433
First Language
PT-BR
Primarily Uses
RM2k3
Got it, sorry, it was just an add-on to a more practical way of checking true/false.
 

Luth

Veteran
Veteran
Joined
Apr 29, 2014
Messages
148
Reaction score
69
First Language
French
Primarily Uses
RMMZ
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:
 

Mr_Petue

Villager
Member
Joined
Sep 24, 2021
Messages
5
Reaction score
1
First Language
german
Primarily Uses
RMMZ
[mod]@Mr_Petue please do not make posts that have nothing to do with the rest of the thread[/mod]

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!
 
Last edited:

Latest Threads

Latest Profile Posts

What the writer wrote: "The curtain is blue."
The readers: "There must be a hidden meaning behind this, perhaps to convey the character emotions ...".
What the writer has in mind: "The curtain is frickin' blue".
Time to share something!
hmZFwQe.png

I made these a while ago for my game. I took reference from various huts in Africa.
Have a great night! :D
I really need to buy a new mouse. Mine's keeps double-clicking and makes me waste A LOT of time eventing
How come there's no spooktober game jam? I thought horror maker games were some of the most popular genre out there...
"I didn't know X song was about that!" Uh... why? Do you not listen to the lyrics? I mean, I guess that makes sense. We live in a world where nobody listens, but everyone wants to be heard.

Forum statistics

Threads
115,843
Messages
1,093,358
Members
151,031
Latest member
Florian973
Top