![]() Var event = $gameMap.events().filter(function(event) ) Then do a conditional branch for self switch A being OFF (with an else branch), like so: Go ahead and add a Play SE for whatever sound you want to play when a switch is hit. Literally the only event commands I'm using here are Play SE, Conditional Branch, Set Movement Route and Script. This will be done almost entirely with Javascript. Then we'll loop through the switch events again to check that all of them are OFF, and if so show the player they won with accompanying victory ME. In the else branch, we'll do the move route for the switch being pressed into the off position, and a line of script to turn self switch A OFF.įollowing the conditional branch, we'll do some magical Javascript jiggery-pokery to loop through all the switch events and find the events adjacent to them, then flip the self switches for those events so they toggle (with a sound effect to accompany the change). I called mine Switch, but again you can call yours anything you want.īasically what we're going to do is play a switch sound, then in a conditional branch for self switch A being OFF, we're going to have a move route to animate the switch being pressed and a line of script to turn the switch event's self switch A ON. Speaking of which, let's make this magical common event that will do everything for us forever! (except make toast, common events are pretty lousy at that, even with Javascript). Don't worry about what order they're in, the common event will handle it, trust me. Here's what your lights should look like in their grid. This is important, as it prevents the switch from "looking" towards the player when interacted with, causing a weird graphical glitch. The first event page will have the "off" graphic and be set to Direction Fix. Here, I'm going to use the red button for off, and change it to green when it's on. ![]() Obviously it needs to have a graphical representation of "on" and a graphical representation of "off". ![]() ![]() Bear in mind that if you use different graphics the animation move route in the common event may need to be amended accordingly. For the purposes of this tutorial, I'm using !Switch1 from the RTP but you can use whatever you want. Behold the power of code!įirst, create your lights. That's right, you will not be putting a single event command into the switches except "Common Event". Inspired by GoodSelf's evented Lights Out puzzle tutorial, I'm going to take you through how to achieve the same effect with Javascript and a single common event. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |