Script for XP that allows you to turn on another's self switch?

Brandon Thomason

Dragon Rearling
Veteran
Joined
Oct 21, 2017
Messages
34
Reaction score
6
First Language
English
Primarily Uses
RMMV
Hello. I'm looking for a script for RPGmaker XP that allows you to turn on a switch of one object via an event of another object. Plain and simple. If I use control switches, it could get really jam packed with various global control switches, which will only be actually turned on and off once in game.
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
638
Reaction score
416
First Language
English
Primarily Uses
RMVXA
You should be able to use:
Code:
$game_self_switches[[MAP_ID, EVENT_ID, KEY]] = true
# OR
$game_self_switches[[MAP_ID, EVENT_ID, KEY]] = false
MAP_ID can be the ID of any map (e.g. 1 for map 1). If you want to use the current map, use $game_map.map_id. Event ID is the ID of the event (e.g. 3 for event 3). KEY can be "A", "B", "C" or "D", whichever self switch you want to toggle.

EDIT: Also, if there isn't enough space in the script call, you can do this:
Ruby:
key = [MAP_ID, EVENT_ID, KEY]
$game_self_switches[key] = true
# OR
$game_self_switches[key] = false
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
39,394
Reaction score
12,925
First Language
English
Primarily Uses
RMMV
Remember that XP does not refresh the map within the Game_Self_Switches class (or in Game_Switches, or in Game_Variables), but within the Game_Interpreter class, so if it's an event on the current map, you're going to have to do that as well:

Code:
$game_self_switches[[MAP_ID, EVENT_ID, KEY]] = true
$game_map.need_refresh = true
 

Brandon Thomason

Dragon Rearling
Veteran
Joined
Oct 21, 2017
Messages
34
Reaction score
6
First Language
English
Primarily Uses
RMMV
Ok, and how do I check another event's self switch?
 

KK20

Just some XP Scripter
Veteran
Joined
Oct 11, 2018
Messages
173
Reaction score
62
First Language
English
Primarily Uses
RMXP
Literally the same script call, minus the equal sign and the value after it. No need to refresh either.
 

Brandon Thomason

Dragon Rearling
Veteran
Joined
Oct 21, 2017
Messages
34
Reaction score
6
First Language
English
Primarily Uses
RMMV
so, like Conditional Branch: Script: $game_self_switches[[MAP_ID, EVENT_ID, KEY]]
???

That throws an error

error.png
 

A-Moonless-Night

WINTER IS COMING
Veteran
Joined
Mar 17, 2012
Messages
638
Reaction score
416
First Language
English
Primarily Uses
RMVXA
It needs to be $game_self_switches, all lower case.
 

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

Latest Threads

Latest Profile Posts

lunarrosecrow wrote on hiddenone's profile.
please don't lurk hiddenone I'm quarantining!!!
lunarrosecrow wrote on Edward.T's profile.
Hello Edward sorry to bother you and didn't start a conversation cause I thought i'd be a little weird or disrespectful but I was wondering do you still have your Generator resources you posted as the links on the page are dead?
Stream will be live shortly! It is my birthday, and thus I am doing an extended stream! I will be doing a variety of things. Among the activities I will be doing: Playing Oceanhorn: Monster of the Uncharted Seas, art, and some Text Adventure~ Feel free to drop by!
It would be cool if you could "copy as code" event commands :< .
Just managed to recover my Yahoo e-mail that i lost 3 months ago. Turns out an IP from U.S had hacked it and set the pass back to normal.. Like WTF ?

Forum statistics

Threads
99,485
Messages
965,921
Members
131,111
Latest member
HannyBee21
Top