◆Comment:Hold action button (Z / Enter) to push/pull objects
◆If:Button [OK] is pressed down
◆Comment:Await further input
◆Loop
◆If:Button [OK] is pressed down
◆Comment:--- Get move direction ---
◆If:Button [Down] is pressed down
◆Control Variables:#0025 dir = 2
◆
:Else
◆If:Button [Left] is pressed down
◆Control Variables:#0025 dir = 4
◆
:Else
◆If:Button [Right] is pressed down
◆Control Variables:#0025 dir = 6
◆
:Else
◆If:Button [Up] is pressed down
◆Control Variables:#0025 dir = 8
◆
:Else
◆Control Variables:#0025 dir = 0
◆
:End
◆
:End
◆
:End
◆
:End
◆Comment:--- Process input direction ---
◆Comment:Check passability
◆Script:var switchId = 8; // ID of switch to store result in
: :var d = $gameVariables.value(25); // direction variable
: :var e = this.character(0); // this event
: :var p = $gamePlayer, g = $gameMap; // shorthand
: :$gameSwitches.setValue(switchId, false); // default
: :if (d > 0 && e.isMapPassable(e.x, e.y, d)) {
: : if (p.isMapPassable(p.x, p.y, d)) {
: : if (g.eventsXyNt(g.roundXWithDirection(e.x, d), g.roundYWithDirection(e.y, d)).length === 0) {
: : var cEvs = g.eventsXyNt(g.roundXWithDirection(p.x, d), g.roundYWithDirection(p.y, d));
: : if (cEvs.length === 0 || cEvs.every(function(ev) { return ev.eventId() === this.eventId(); }, this)) {
: : $gameSwitches.setValue(switchId, true); // pass!
: :} } } }
◆Comment:Check result
◆If:008: MoveIsOK is ON
◆Set Movement Route:Player
: :◇Direction Fix ON
: :◇Script:this.moveStraight($gameVariables.value(25));
: :◇Direction Fix OFF
◆Set Movement Route:This Event (Wait)
: :◇Script:this.moveStraight($gameVariables.value(25));
◆
:Else
◆Comment:Check again in a few frames (60 fps)
◆Wait:6 frames
◆
:End
◆
:Else
◆Comment:Push/pull button released -> end loop
◆Break Loop
◆
:End
◆
:Repeat Above
◆
:End