RMMV What am I missing in my script? (Controlling Selfswitches of other events)

Ionenschatten

Villager
Member
Joined
Jul 21, 2017
Messages
14
Reaction score
4
First Language
german
Primarily Uses
Other
Hey there!
I am trying to make a puzzle right now where you have to turn on the right 2 orbs out of 6.
My basic logic idea is that wrong orbs add +1 to the "wrong var" and right orbs +1 to the "right var"
If you interact with an orb it starts glowing to indicate it's turned on.
If you interact with any orb a second time it checks if wrong var=0 and right var=2 is and if yes the puzzle is completed.
Now the difficult part.
If no, a sound is played, all vars are reset to 0 and I have to reset all orbs.
The thing is that I'm working with self switches instead of normal switches to learn how to do it. If you have the wrong combination I want the orb you're interacting with to not only turn off it's own Selfswitch to stop the glowing to indicate it's turned off again but also to turn off all the other orb's self switches.
TL:DR How do I make one event turn off the self switches of other events?
I've been using this table so far.
1600797529800.png
Where is the mistake in those? I'm sadly no coder myself.
 

Ronove

♫꒰・‿・๑꒱
Veteran
Joined
Mar 12, 2012
Messages
1,062
Reaction score
362
First Language
English
Primarily Uses
RMMV
1600798295182.png
Does it work if you have it set up like the table example? This is how I have mine and it works. I don't know if you can just do a large script command this way like you're doing, so I usually just do one script command per self-switch.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,605
Reaction score
951
First Language
Portuguese - Br
Primarily Uses
RMMV
Hi ^^
I can't see anything wrong from here...
I mean, I'm supposing that you are not using the same key variable for all switches, I think you put into that way just to illustrate how you are doing right?
If not:
When you put "//" You are turning the code in a comment, so I guess that is the reason for it not be working.
Try to put the array directly on the script call, instead of repeating the same key variable for every code.
Otherwise, maybe you have another event turning the self switches on again?
 

SeaPhoenix

Veteran
Veteran
Joined
May 14, 2015
Messages
240
Reaction score
212
First Language
English
Primarily Uses
RMMV
You need to set the key to a value before calling the $gameSelfSwitches.setValue function. (And right now your key is being commented out, since it has // before it, which means it's never being run). You can use // to make comments to yourself.

So for example, you can do this instead where you write the key in the function itself:
$gameSelfSwitches.setValue([44, 2, 'A'], false);

Or you can do it the way the poster above mentioned.
 

Ionenschatten

Villager
Member
Joined
Jul 21, 2017
Messages
14
Reaction score
4
First Language
german
Primarily Uses
Other
I mean, I'm supposing that you are not using the same key variable for all switches, I think you put into that way just to illustrate how you are doing right?
Yea totally haha it's totally not me being a total idiot in coding haha :oswt:
That was indeed my mistake. I just spread out all commands, put the key set commands out of the comment and above the key commands and now it works!
:ewat:
MAGIC!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Ami
--- Diary ---

M.Mage: It's the F.Mage's Diary. While she isn't here,i can read it.

May, 10: I'm hurt after the battle with the Minotaur. But luckily,F.Healer heal me with her Heal-2. That why,i Fall in Love with her.

M.Mage: Eh???
So... some of my Desktop hardware has kicked it apparently (still trying to figure out what and how at the moment :/ ) .... yay?
Stream will be live shortly with some Darkest Dungeon! Feel free to drop by!
Made a HUGE (YYOOOOJJ) Update to Monstructs and moving towards a Steam Early Access release!
A skill type called: "Rumagic". The intention is Magic with Rum(that pirates drink)
Does it sound strange in English?

Forum statistics

Threads
104,220
Messages
1,004,781
Members
135,730
Latest member
sosmax
Top