Jump to content
Ash1977

How to make a button that goes down when you stand on it and up when you don't

Recommended Posts

So I've started to get into RPG Maker with my son, but I'm not a programmer. I've looked all over, but can't find or don't understand the things I've read. In simple terms, how do I make a button that goes down when you stand on it and back up again when you're not stood on it?

I've got it to go down:
>Set Move Route: This event (Wait)
:$>Turn Down
:$>Turn Left
:$>Turn Right
:$>Turn Up

It then stays down. How do I get the event to store the players location and the event's location, compare them and then go back up if the two aren't the same?

(I'm slowly working towards making a puzzle where the character or a boulder can stand on a button to open a door.)

Thanks very much for your help!

Share this post


Link to post
Share on other sites

 

10 hours ago, Ash1977 said:

make a button that goes down when you stand on it and back up again when you're not stood on it

First make a new event

And at the left you can find some options, look at the one called "Priority". There you can find some options

Spoiler
  • "Below character" (the button will be under the character)
  • "Above character" (the button will be over the character/ the character will be under the button)
  • "Same as character" (the character can't pass over or under the button)
  • You can choose any of these, I recomend you use "under the character".
Spoiler
  • "Action button": The event will trigger the command you put in it when the player press the "confirm button" (Z, space, Intro, etc).
  • "Player touch", "Event touch": Player touch and event touch are not so different, the event will trigger when the player touch the event and event touch is the same but the other way around.
  • "Autorun": This means the event will trigger on its own, and it won't stop unless you give it a condition to stop, if there is no condition for this the event to stop then it will stop the hole game just because it can.
  • "Parallel process": Wich means the event will trigger when another event that is on another map or in the common event page give it the comand to do so. This can be done with switches, for example: Event one has the switch "Trigger Event 2" on its command list and Event 2 has the "Trigger Event 2" OFF on its conditions. So when Event one says to turn ON the switch"Trigger Event 2", Event 2 will execute its command list.
  • For this event use Player touch.

And to make the event a button on the game just select the character sheet of the "!switch1". Recomend to select the button sprite.

Spoiler

RPG Maker has default graphics, you can set a graphic on the event by double clicking on the graphic option, use the "!switch1" for example and just select the graphic you want, press "OK" and its done, the event has a graphic.

image.thumb.png.32af7babe088f3e462933718f49ed423.png

Set the event the same way its shown on the image above ("Type: Fixed", "Priority: Under Character", "Trigger, Player touch") the rest leave it as default, later we'll come back to make some changes.

Now understanding that, we can proceed to programate the event.

Use "Control Switches" and set two new customized switches to use it for the button turning up (Button do not being pressed) and also make one for the button turning down (button being pressed)

Spoiler

Use "Control Switches" found at the first page on the section "Game progression", there use the switch "Single" and to set a new customized switch press the option next to it. And give it a name that makes sense and you can remember to use it for the button turning up (Button do not being pressed). Also make one for the button turning down (button being pressed)

image.thumb.png.e9579a641545cc636cb4894486810e36.png

And here, give it a name.

image.thumb.png.018daede0bae9ba46ccdc37a97894fb5.png

Select the next blank space to make a new switch, give it a new and different name that defines the action you want it to trigger.

image.thumb.png.e245232d91e63d9ebe051adf0d2f39c3.png

 

I named the first switch "Switch pressed" (for the button being pressed) and the another one is "Switch unpressed?" (for the button do not being pressed).

Now just add this two switches as two different commands, the first being the button being pressed ON, and the second command as the button do not being pressed OFF. And finally, make sure that the event holds the switch of thee button do not being pressed.

Next let's copy this page on this event, this time with the graphic of the button being pressed, the switch this page contains must be the one of the switch being pressed and the command list must be blank, there is no need to add any command here.

It should looks like this:

Spoiler

Page 1:

image.thumb.png.034a0a0d886cdcaad7aeeaf673945a8a.png

Page 2:

image.thumb.png.0deb913ecc58d90683b174ef5524fc52.png

Like this the ev-- the button will turn down when the player step on it, yet it won't change back when the player goes away from it. For this, I believe you can add some events around this button that will help to change the graphic when the player touch them.

So, make another event without graphic set, so it won't be seen on the game when being played, the priority is "Under character", the trigger will be "Player touch".

Now, add two commands the first switch (the one that checks the switch being pressed) isn't activated (selected OFF), the second command with the second switch (the one that checks if the switch isn't pressed) must be activated. Now just copy and paste this events around the button, like this when the player touch this events (or simply walks away touching this events) the switch of the button pressed will deactivate and the button will look like if it weren't pressed.

And you must have something like this:

Spoiler

The new event looks like this.

image.thumb.png.02c6867b2ab7d490401f59450495ea5a.png

And the events around the button looks like this.

image.png.61b8465c7871e4b3ad77cdd0a48741eb.png

And finally, since the button won't appear when we test our game. Create a last event with the trigger "autorun", the comand it must have are the switch of the button do not being pressed ON, and the second command is erase event, so it won't deal with any problem for being autorunned.

Spoiler

image.thumb.png.0845c1b662ead477731493da6576f202.png

Now just save the project and test it.

Spoiler

PD: By the way, you still can use the animation for the button using conditionals.

Like this:

playerattheright.png.0134f03f5b4b4b453a158406e30cdfd5.png

Since the player will move to the right, the event must evaluate the direction of the character.

image.thumb.png.45c6b9c565fa8969a3e3a365052146c9.png

And like this when the character is facing certain direction something will happen, in this case, you can use the set move route for the event.
It should look like this:

image.thumb.png.cd611bc4f770fe65a967171eb545ee6c.png

Do this with the other events that surround the button, with the one that is down, the conditional must be facing down, the event to the left facing left, etc.

And for the button, you can do this on its first page:

image.thumb.png.954e238017fc423995921a242f3aff1b.png

Now the button is animated whenever it is pressed or not.

Sorry for the long anwer, I got exited, I hope this helped 👍.

Edited by Natsuki-9

Share this post


Link to post
Share on other sites

I personally like using location variables

Spoiler

image.png.5025303f192ac4757e25d541b28e9741.pngimage.png.b80dc814c1314d2742039bc537aeefa3.pngimage.png.b9760cabd0b9368f979c7b39147ef3f1.pngimage.png.0febe6ea0403bd6408097cda618fefd2.pngimage.png.833888c6baf855d951db64da4c486a41.png

image.png.d381c3ab48b0ba5bbf7ee06371a42f72.pngimage.png.f39a2148ee37b63db486785a94d5c037.pngimage.png.ad35dee705da6dd9093dc6d92dd9ed79.png

The last page is not used but you could change the conditions so that once the object is on the switch that the object does not move again and then the switch can be set to the last page so that it does not run in parallel.

The self switch command for event 5 is the door that opens.

Then when you pass the door, you could do this

Spoiler

image.png.20e0dfc0623cb0d52dcdd282391bf579.png

 

 

 

Edited by roninator2
  • Like 2

Share this post


Link to post
Share on other sites

Thanks both very much for your help. I've created something that almost works just for the button, but it only goes back up when the player is not on the button's X OR Y coordinates. What have I done wrong here? I want it to be whenever the player is not on the button's X AND Y coords. Hmm...

 

 

Button event 1.JPG

Button event 2.JPG

Share this post


Link to post
Share on other sites
Spoiler

Conditional Branch: (Script)
$gamevariables[1] == $gamevariables[3] && $gamevariables[2] == $gamevariables[4]
> Event Contents
>>Else
> Other Contents

 

I wouldn't even use two pages, but one. There's no need for a selfswitch if coords are being used, at least, not for the basic eventing.
 

Share this post


Link to post
Share on other sites
8 hours ago, PhoenixSoul said:

There's no need for a selfswitch

There is if you want it to be easier. Changing the graphic instead of changing the switch is more thought process (IMO). I find it easier to see the different graphic on the other page. IF you just do teh move route then when you leave the map and come back it will be reset with an object on top. If that's what the ash1977 is doing.

16 hours ago, Ash1977 said:

What have I done wrong here?

You put the players x and y conditions inside each other.

If you looked at my suggestion, they are separate conditions.

Also why do you need to set the events location into a variable? Does the button move on the map?

I think you got confused with my images. The event coordinates I used is for the boulder that moves onto the switch.

image.png.dc5c991b4435bc6012f955161b685e17.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted