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,392
Reaction score
12,915
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

Chaos17 wrote on Poryg's profile.
Hi, I am following your videos tutorials serie about coding on MV and I am at the third video. Thank you for making it but's a bit hard to follow since you don't show the whole plugin at the end. I had to screenshot the lines between 110-159 because you scrolled so fast on them.
:rtear:
I'm not sure if I should be happy for MZ, or sad for MV.
Not going to lie.... The update's cool and all, but I immediately ran to Mog's site and was like, "Update! Update! Update!" while breathing on the page of his Star Ocean Battle System plugin. :kaoswt:
Ho boi. I can already see the storm of ugly actor faces RTP customizable facesets from MZ are gonna flood. XD
<-- Meet Seith. He begins the story as an apprentice druid, learning to survive in the wilderness by communing with nature and honing his herbalism. Seith has a deep desire to understand the world around him. When wells of chaotic energy begin erupting from the land,corrupting plant, animal and man alike, Seith finds himself on a journey to discover just what this means for the fate of his home, the land of Myarr.

Forum statistics

Threads
99,461
Messages
965,655
Members
131,072
Latest member
Ragatoni
Top