"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,291
Reaction score
1,789
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,791
Reaction score
1,638
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
965
Reaction score
470
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,531
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,791
Reaction score
1,638
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
44,163
Reaction score
15,541
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,791
Reaction score
1,638
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
965
Reaction score
470
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 Posts

Latest Profile Posts

"16. Do NOT contact other members by private message, on the forum or status feed, inviting them to put additional tools (such as leaderboards, ads, etc - whether yours or another person's) into their game."
Oh no. Necessity is the mother of invention. Do I want to know what happened?
Early WIP for my next entry. Since it's early you're going to need to wait a little longer than usual. What's that? You'll find out in my next update!
12.PNG
20 festive cards can now be unlocked in BiteMe!

The cards are permanent, but can only be unlocked in December!
Once the year is over, you won't be able to unlock the cards, or to upgrade it.
https://johndoenews.itch.io/biteme-storymodeCard141-160-Ad.png
Finally showing some updates again

Forum statistics

Threads
117,183
Messages
1,105,254
Members
153,310
Latest member
Orhez
Top