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?
How do I change an event's self switch through a script command?
● ARCHIVED · READ-ONLY
-
-
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:
Code:$gameSelfSwitches.setValue(key, true/false); // key = [mapId,eventId,name] -
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!. -
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 :) -
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:
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:but of course it doesn't work =($gameSelfSwitches.setValue([43, 9, 11, 'A'], true) -
You really should have started your own post for this, but since we're here anyway: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:but of course it doesn't work =($gameSelfSwitches.setValue([43, 9, 11, 'A'], true)
JavaScript:[9, 10, 11].forEach(eventId => $gameSelfSwitches.setValue([43, eventId, 'A'], true)); -
Thanks! :LZSjoy: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)); -
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) -