How do I change an event's self switch through a script command?

Status
Not open for further replies.

Drako King

Villager
Member
Joined
Jun 8, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
I've set up an event; within the event there are move routes for multiple events. I would like to know how to use JavaScript in a Script command from one of the move routes to change a different event's self switch so that it can display text messages on the screen. 


Right now I'm looking through the rpg_core rpg_objects and the other .js files and am currently lost as to what command I would use. I'm looking for any suggestions. 


I'm messing with
 


$dataMap.event(17).command123[1];



but it's still giving me a type error saying that undefined is not a function. I'm not that great with JavaScript, so I'm not sure how close I am to figuring it out. I found that command123 is a Game_Interpreter command meant to change the self switch, and I see that the Game_Event prototype has a Game_Interpreter as a property. Can anyone maybe give some advice?
 
 
Last edited by a moderator:

Astfgl66

Regular
Regular
Joined
Jan 5, 2016
Messages
764
Reaction score
637
First Language
French
Primarily Uses

Drako King

Villager
Member
Joined
Jun 8, 2016
Messages
5
Reaction score
0
First Language
English
Primarily Uses
Hey!


Please see this google doc for the official list of script calls equivalent of event commands:


https://docs.google.com/spreadsheets/d/1-Oa0cRGpjC8L5JO8vdMwOaYMKO75dtfKDOetnvh7OHs/edit?pref=2&pli=1#gid=0


The particular command you want is:



$gameSelfSwitches.setValue(key, true/false); // key = [mapId,eventId,name]

Thank you so much!!! That command did exactly what I was looking for. Also, this document you have provided me is a huge deal to me, so thank you for that!. 
 

Shaz

Keeper of the Nuts
Global Mod
Joined
Mar 2, 2012
Messages
46,153
Reaction score
16,971
First Language
English
Primarily Uses
RMMV
There's also an Outer Self Switch plugin that comes with the engine (it's one of the Kadokawa plugins) that lets you do this through a plugin call.


Personally I'd just use the command above too, as you've got to either add a plugin command or a script call, and going with the script call means one less plugin that's required.  I just wanted to put it out there though :)
 

seyfer110

Regular
Regular
Joined
Jan 9, 2014
Messages
81
Reaction score
11
First Language
English
Primarily Uses
RMMV
Sorry for the necro, but my question is Close-related to this thread, so...
Is it possible to change self-switches of Multiple events with a single script call?
So that instead of doing this:
bandicam 2021-04-14 18-41-37-206.jpg
which turn on self switch A for three consecutive events, I can use a single script to change all three of them at once.
I've tried something like this
Code:
$gameSelfSwitches.setValue([43, 9, 11, 'A'], true)
but of course it doesn't work =(
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,869
Reaction score
7,947
First Language
English
Primarily Uses
RMMZ
Sorry for the necro, but my question is Close-related to this thread, so...
Is it possible to change self-switches of Multiple events with a single script call?
So that instead of doing this:
View attachment 186123
which turn on self switch A for three consecutive events, I can use a single script to change all three of them at once.
I've tried something like this
Code:
$gameSelfSwitches.setValue([43, 9, 11, 'A'], true)
but of course it doesn't work =(
You really should have started your own post for this, but since we're here anyway:

JavaScript:
[9, 10, 11].forEach(eventId => $gameSelfSwitches.setValue([43, eventId, 'A'], true));
 

seyfer110

Regular
Regular
Joined
Jan 9, 2014
Messages
81
Reaction score
11
First Language
English
Primarily Uses
RMMV
You really should have started your own post for this, but since we're here anyway:

JavaScript:
[9, 10, 11].forEach(eventId => $gameSelfSwitches.setValue([43, eventId, 'A'], true));
Thanks! :LZSjoy:
 

wadyBlue

Villager
Member
Joined
Aug 5, 2023
Messages
8
Reaction score
0
First Language
English
Primarily Uses
RMMV
from what I see, this script requires to set the map ID and event ID of the event to set the self switch.
Is there a way in a script to affect the event where it run from.
I was trying to get the event copier from yanfly and want to set a bunch of gatherable that have random content
My idea was to use the self switches
The initial page is to randomize the currect gatherable
if on self switch A, normal gather (page 2)
if on self switch B, special gather (page 3)
if on self switch C, secial gather B (page 4)
when looted, use self switch D (page 5)

every week in my game time the self switches are resetted so looted gatherable are reset
my script so far to set the self switch but don't know if we can set the self switch per event script

var gathChance = Math.randomInt(100);
if (gathChance <= 50) {
$gameSelfSwitches.setValue(A,true);
};
if (gathChance >= 51 && gathChance <= 95) {
$gameSelfSwitches.setValue(B,true);
};
};
if (gathChance >= 96) {
$gameSelfSwitches.setValue(C,true);
};

===============

*Edit: found the way noting for other who might struggle with it:
var key = [mapId, eventId, A-D]
$gameSelfSwitches.setValue(key, true);
to get the current map its :
$gameMap._mapId
to get the current event Id its:
thist._eventId
and the self switch either : 'A' , 'B' , 'C' or 'D'
so either use temporary var (like the var key) or directly
like that:
// setting the temporary variable
var key = [$gameMap._mapId, this._eventId, 'A'];
//
$gameSelfSwitches.setValue(key, true);
(In this example will turn the current event self switch A to on)
 
Last edited:

Ms Littlefish

Time Traveling Victorian Vampire
Global Mod
Joined
Jan 15, 2014
Messages
8,994
Reaction score
14,524
First Language
English
Primarily Uses
RMMV
@wadyBlue , please refrain from necro-posting in a thread. Necro-posting is posting in a thread that has not had posting activity in over 30 days. You can review our forum rules here. Thank you.
 
Status
Not open for further replies.

Latest Threads

Latest Profile Posts

Yknow what? Im seriously considering recruiting a manager to oversee my games development.
Because I cannot focus or complete these tasks by myself. I need someone to give me orders, without having them be my boss.
yp_4vS.png

Remember my latest plugin for rpg maker mz:

Acknowledgement Window is now available!

Take a look here:

Got my focus back, 9/59 maps have the door fix in place now.
Making a small RMMV project has made me realize that I've never actually made a credits sequence for a game.

Forum statistics

Threads
136,802
Messages
1,270,177
Members
180,557
Latest member
wellaa
Top