Hey guys, you've all been extremely helpful to me in the past, so I was hoping you could help me with this as well. I was wondering if there is a specific way to trigger a self switch in MV using scripts. Now, before you tell me that this can be achieved from a reference in the Big Spreadsheet of MV Scripting Knowledge (If that's not what it's called, it should be what it's called!) I know that it is in the spreadsheet, and I tried that. It did not work. Maybe my problem is that I am trying to initiate a self switch from another self switch-triggered event, without first turning the self switch off so that the self switch triggered event will stop. I don't really, know, like, does the second self switch-triggered event have to be on autorun or something? Anyways, I hope you can help! Thank you in advance!
MV Self Switch?
Learning JavascriptWith event commands, an event can only ever toggle its own self-switches.
Note that only map events have self-switches; troop events and common events do not. (Common events called via the Common Event command are inserted into the current event, so follow that event's self-switch rules.)
For reference, here's a couple of examples of correct script calls:
Note that only map events have self-switches; troop events and common events do not. (Common events called via the Common Event command are inserted into the current event, so follow that event's self-switch rules.)
For reference, here's a couple of examples of correct script calls:
$gameSelfSwitches.setValue([1, 2, 'A'], true);
This says "set the value of map 1, event 2, self-switch A equal to true", i.e. turn it on.$gameSelfSwitches.setValue([4, 10, 'C'], false);
This says "turn off self-switch C of event 10 on map 4".
A, B, etc) must be enclosed in 'single' or "double" quotes. Also the [square] and (round) brackets are necessary, and code is case-sensitive.(tip for your next request for help, don't be afraid of the Enter key)
Whatever happens with your self-switches, the event that's doing its commands will do them until it reaches the bottom of the page. Changing self-switches mid-event so that the current page's self-switch condition is now invalid will not interrupt the commands in its page.
Make sure that's not what you're trying to do, then refer closely to the Holy Script Call Spreadsheet.
Whatever happens with your self-switches, the event that's doing its commands will do them until it reaches the bottom of the page. Changing self-switches mid-event so that the current page's self-switch condition is now invalid will not interrupt the commands in its page.
Make sure that's not what you're trying to do, then refer closely to the Holy Script Call Spreadsheet.
@caethyril, I am using a map event to change the self switch of the aforementioned map event, so we're all good there! I will try using your scripts and get back to you on if they work for me or not.
@CHKNRAVE, I will remember the enter key next time! Do not worry, all of the self switch commands happen at the bottom of the page.
Your initial message made me think you have an autorun event that keeps replaying. Is that not the case?
That'd mean it's still the last page in its event to have a valid condition.
That'd mean it's still the last page in its event to have a valid condition.
No, the first page is autorun, which changes the self switch on, therefore activating the problematic event page in question.
And that problematic event page, what's the problem with it exactly?
If you happen to have trouble getting it to work following the script call examples I cited, maybe post some screenshots of the troublesome events. 🙂
Just to note: this is true unless the event page trigger is set to Parallel (not sure if that's the case here). Parallel events run on an interpreter attached to the event: when they switch page that interpreter is deleted. 😅
Original thread: https://forums.rpgmakerweb.com/threads/self-switch.127559/