Tutorial-Blog Eventing a Push/Pull System

Xelion

Veteran
Veteran
Joined
Apr 18, 2012
Messages
105
Reaction score
147
First Language
Spanish
That's a pretty good way of donig it! When I did boulder puzzles in my 2000/2003 projects they only had a simple push mechanic and I remember just telling the player to exit and reenter the scene if they got stuck.
 

Touchfuzzy

Rantagonist
Staff member
Lead Eagle
Joined
Feb 28, 2012
Messages
7,691
Reaction score
9,824
First Language
English
Primarily Uses
RMMZ
That's a pretty good way of donig it! When I did boulder puzzles in my 2000/2003 projects they only had a simple push mechanic and I remember just telling the player to exit and reenter the scene if they got stuck.

I've always included a reset button of some sort even with push only puzzles.

The method that @hiddenone used to do the pulling though is pretty spiffy. Definitely will be yoinking it myself in the future.
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,610
Reaction score
5,510
First Language
english
Primarily Uses
RMMZ
Having to reset puzzles over and over while testing is why I came up with the pulling part. :rswt After rolling a rock against a wall one too many times, I decided it would just be easier if I figured out a way to let players fix any mistakes they made without having to reset the entire puzzle.
 

Jennavieve

Veteran
Veteran
Joined
Oct 21, 2020
Messages
90
Reaction score
87
First Language
English
Primarily Uses
RMMZ
This blog post was super helpful as a guideline. I would have had no idea how to even begin implementing a push/pull system if it wasn't for this. Thank you so much!

I used this post as a basis for understanding how a push/pull system should work but took out the scripting and used if/else clauses exclusively just because it was easier for me to wrap my head around.

Push-Pull.png

I also had no need for any of the direction fix calls so I left that out. For anybody else who struggles with scripts, this is also a functional option.
 
Last edited:

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,956
Reaction score
1,664
First Language
English
Primarily Uses
RMMV
I wonder if I can make moving platforms w/ this method...
 

ulosbal

Shamach
Member
Joined
Sep 4, 2018
Messages
28
Reaction score
4
First Language
french
Primarily Uses
RMMV
Pushing works very well, I have a problem with pulling
the player moves, not the event.

Capture d’écran 2021-02-05 à 14.48.00.pngCapture d’écran 2021-02-05 à 14.48.31.png
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,612
Reaction score
1,994
First Language
EN
Primarily Uses
RMMZ
@ulosbal: I think the player is in the way. Move routes process 1 command per frame: the player's route has 2 commands before they move, so the event should wait 2 frames before its move, not 1.
 

ulosbal

Shamach
Member
Joined
Sep 4, 2018
Messages
28
Reaction score
4
First Language
french
Primarily Uses
RMMV
Thanks @caethyril that did not solve my problem ... :/

But by adding a few frames at the start of the loop
prevents the player from sliding when you press the arrows before the space bar.
(it was another problem I had)
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,610
Reaction score
5,510
First Language
english
Primarily Uses
RMMZ
@ulosbal Caethyril was right about adding extra wait frames, but for some reason the 'change image' option needs a little longer than 1 frame. So instead of waiting 2 frames, try 3 and see if that works (it did in my quick test, so hopefully it will for you). :)
 

ulosbal

Shamach
Member
Joined
Sep 4, 2018
Messages
28
Reaction score
4
First Language
french
Primarily Uses
RMMV
@hiddenone Yes I have already tried different number of frames until I have too many! nothing works.
I am so close to the goal ...

edit: to solve my problem I did this:
 

Attachments

  • Capture d’écran 2021-02-20 à 13.15.00.png
    Capture d’écran 2021-02-20 à 13.15.00.png
    40.7 KB · Views: 5
Last edited:

Parallax Panda

Veteran
Veteran
Joined
Oct 29, 2015
Messages
1,094
Reaction score
1,337
First Language
Swedish
Primarily Uses
RMMV
I tried to recreate this push/pull system, and as far as I can tell, mine is *exactly* the same as what's shown here. Pushing works fine but pulling crashes the game though.

Would be great if someone could tell me what's wrong since I'm obviously missing something.

Code:
◆Comment:Prep the player for moving
◆Set Movement Route:Player (Wait)
:                  :◇Direction Fix ON
:                  :◇Speed:3
◆Wait:3 frames
◆Loop
  ◆Comment:These conditional branches check if the player is pressing the same
  :       :arrow key as they are facing, which will make the player push the block.
  ◆If:Player is facing Down
    ◆If:Button [Down] is pressed down
      ◆Control Variables:#0004 Pushing or Pulling = 1
      ◆
    :End
    ◆
  :End
  ◆If:Player is facing Left
    ◆If:Button [Left] is pressed down
      ◆Control Variables:#0004 Pushing or Pulling = 1
      ◆
    :End
    ◆
  :End
  ◆If:Player is facing Right
    ◆If:Button [Right] is pressed down
      ◆Control Variables:#0004 Pushing or Pulling = 1
      ◆
    :End
    ◆
  :End
  ◆If:Player is facing Up
    ◆If:Button [Up] is pressed down
      ◆Control Variables:#0004 Pushing or Pulling = 1
      ◆
    :End
    ◆
  :End
  ◆Comment:This Script Call checks if the player is pushing the opposite arrow
  :       :key as they are facing, which will make the player pull the block.
  ◆Script: if (
  :      :($gamePlayer.direction() == 2 && Input.isPressed("up")) ||
  :      :($gamePlayer.direction() == 8 && Input.isPressed("down")) ||
  :      :($gamePlayer.direction() == 4 && Input.isPressed("right")) ||
  :      :($gamePlayer.direction() == 6 && Input.isPressed("left"))
  :      :) {
  :      :$gameVariable.setValue(4, 2);
  :      :}
  ◆Comment:The actual movement of the event and player.
  ◆If:Pushing or Pulling = 1
    ◆Comment:Pushing movement.
    ◆Set Movement Route:This Event (Skip)
    :                  :◇Move away from Player
    ◆Set Movement Route:Player (Skip, Wait)
    :                  :◇Wait:1 frame
    :                  :◇1 Step Forward
    ◆
  :End
  ◆If:Pushing or Pulling = 2
    ◆Comment:Pulling movement.
    ◆Set Movement Route:Player (Skip)
    :                  :◇1 Step Backward
    ◆Set Movement Route:This Event (Skip, Wait)
    :                  :◇Wait:1 frame
    :                  :◇Move toward Player
    ◆
  :End
  ◆Comment:Check if 'ok' is still being held down. If not,
  :       :then the action will end.
  ◆If:Button [OK] is pressed down
    ◆
  :Else
    ◆Break Loop
    ◆
  :End
  ◆Comment:Make variable 0 again, so that the player won't keep pushing/pulling
  :       :if the arrow keys are not being touched.
  ◆Control Variables:#0004 Pushing or Pulling = 0
  ◆Wait:1 frame
  ◆
:Repeat Above
◆Comment:Reset player to their normal form
◆Set Movement Route:Player (Wait)
:                  :◇Direction Fix OFF
:                  :◇Speed:4
◆Comment:Reset variable to 0.
◆Control Variables:#0004 Pushing or Pulling = 0

PushPullCommonEvent.png
And here is the error msg:
PushPullErrorLOG.png


I'm using variable 4 instead of variable 11 but besides that, I can't find any differences?
 
Last edited:

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
2,612
Reaction score
1,994
First Language
EN
Primarily Uses
RMMZ
@Parallax Panda: in your script call you've written $gameVariable, but it's supposed to be $gameVariables (plural variables).

Alternatively, you could remove the script call and add "pull" checks alongside the "push" checks, e.g.
Code:
◆If:Player is facing Down
  ◆If:Button [Down] is pressed down
    ◆Control Variables:#0001 Pushing or Pulling = 1
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Control Variables:#0001 Pushing or Pulling = 2
    ◆
  :End
  ◆
:End
 

Parallax Panda

Veteran
Veteran
Joined
Oct 29, 2015
Messages
1,094
Reaction score
1,337
First Language
Swedish
Primarily Uses
RMMV
@caethyril
Magnificent!

Now it works as it's supposed to, thank you. I read and compared the snippet several times yet I didn't catch it. It's so easy to stare yourself blind to small stuff like that.
 

hiddenone

Lurker Extraordinaire
Global Mod
Joined
Feb 19, 2014
Messages
2,610
Reaction score
5,510
First Language
english
Primarily Uses
RMMZ
@Parallax Panda I'm glad caethyril was able to point out what was wrong, missing 's's is where I often stumble too. :rswt

Don't feel like you have to use the script calls, since using the script calls isn't really necessary to get the event working. It's why I showed how to use event commands as well. Either option would work and the only difference is which way of eventing you're more comfortable with. :)
 

Latest Threads

Latest Posts

Latest Profile Posts

would i get in trouble if i didn't take out the computer icons on my fake computer screen i had Discord, Messanger, and rpg maker up
Auto-Adjust Text Outline, Run Common Events on Transfer | RPG Maker News #111

I sweep the floor. My brother, "You didn't do a good job. There are dust bunnies everywhere." He sweeps the floor weeks later. "I just swept. Why are there dust bunnies everywhere?" Me," Guess you didn't do a good enough job."
Today, I tortured my internet by downloading 20 files at once and then I played a guessing game as to which would finish their download first :kaojoy:
Oh god, just watched HawkZombie's stream of my game and realised that *none* of the branching scenes work properly. One has no character graphic, one soft locks due to a passability issue, and one doesn't have its autorun set to the right trigger. I've got first prize in the bag, baby.

Forum statistics

Threads
113,791
Messages
1,077,510
Members
147,837
Latest member
Fenrir_
Top