Stepping on a Switch

Hekudan

Villager
Member
Joined
Jun 5, 2014
Messages
25
Reaction score
0
First Language
Spanish
Primarily Uses
Can't figure how to make a switch work like other games I've played, for example:

There's a switch on the floor, when you step on it, it will have a move route so it changes appearance to a pressed switch, but when you move away it deactivates (move route again, changing appearance to an unpressed switch). The point of this is: you need to put a crate on the switch so it can remain pressed.

Saw some tutorials but they don't have the option to deactivate when you move away from the switch, and that would make a game more interesting.

Any help is well appreciated :kiss:
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Switch event has 3 pages. All set to Below Player. Also set all to THROUGH (I THINK this is needed in order for the crate event to be able to be pushed onto it - I have a feeling events don't look at the priority of other events - they just look at the THROUGH).

To make things easy, go to the Region layer and paint the tile the switch is on with one of the region blocks. Note the id (I'll use 50 as an example)

Page 1 has switch in "off" position (not stepped on), and trigger is Player Touch.

Event command is simply Control Self Switches A = ON

Page 2 has switch in "on" position (stepped on), and trigger is Parallel Process. Condition is Self Switch A

Event commands should look like this:

Conditional Branch: Script: $game_player.region_id != 50 Control Self Switches A = OFFBranch EndWait 10 FramesPage 3 has no graphic and no commands and Action Button trigger. Condition is Switch [????]: Box in PlaceNow on your box/crate event, have 2 pages.

Both pages will have the crate image, make sure you check the Direction Fix button.

First page will have these commands:

Set Move Route (This Event): Move Away From Player (Wait for completion)Conditional Branch: Script: $game_map.events[@event_id].region_id == 50 Control Switches [????]: Box in Place ONBranch EndThe second page will be conditioned by that switch as well and will have no event commands.This means once the box has been moved onto the switch, it can't be moved off again.

At the point where you turn that switch on, you would also do whatever else you need when the box is over the switch - open a door, whatever. In fact you'd probably want to do that too in the switch event when the player steps on it, and undo it in the second page when the player steps off again.
 
Last edited by a moderator:

Hekudan

Villager
Member
Joined
Jun 5, 2014
Messages
25
Reaction score
0
First Language
Spanish
Primarily Uses
What's with the script?

Can't understand everything else after that without knowing where the script came from and why a script :dizzy:
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
In the Conditional Branch, at the bottom of the last page, is the Script command. It's just a shortcut. You could do it all using several Control Variables and Get Location Info commands (with different variables for each one) and then a Conditional Branch based on one of the variables.

So just go Conditional Branch, click on tab 4, check the bottom option for Script, and type in everything I put on the line after Script:

Oops ... noticed a typo there as well. I put (@event_id) but it should be [@event_id] - fixed now

This is how you would do them both, without using the Script call in the Conditional Branch. I'll use variables 1, 2 and 3, but you'd have to use different ones probably.

Switch event, page 2:

Code:
Control Variables [0001] X = Game Data > Character's > Player's > Map XControl Variables [0002] Y = Game Data > Character's > Player's > Map YGet Location Info (command under Map on tab 3 of event commands):  [0003], Region ID, Variable[0001][0002]Conditional Branch: Variable [0003]: Region ID != 50  Control Self Switches A = OFFBranch EndWait 10 Frames
Crate event:
Code:
Set Move Route (This Event): Move Away From Player (Wait for completion)Control Variables [0001] X = Game Data > Character's > This Event's > Map XControl Variables [0002] Y = Game Data > Character's > This Event's > Map YGet Location Info (command under Map on tab 3 of event commands):  [0003], Region ID, Variable[0001][0002]Conditional Branch: Variable [0003]: Region ID == 50  Control Switches [????]: Box in Place ONBranch End
 
Last edited by a moderator:

Hekudan

Villager
Member
Joined
Jun 5, 2014
Messages
25
Reaction score
0
First Language
Spanish
Primarily Uses
Yea.. another problem would be, I don't use variables or get location info options because I don't understand what they are for.

Any other answer easier to understand?
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
If you don't understand variables, then it's time to take a look through the beginner tutorials on the site. Do a search for Variables Guide and it should bring up a tutorial :)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
Any other answer easier to understand?
Unfortunately, no - variables are the basic building blocks of anything more complex than a "go from X to Y" map-quest.
If you have problems finding the mentioned variables guide, follow the link in my signature - the variables guide is one of the tutorials linked there.
 

Hekudan

Villager
Member
Joined
Jun 5, 2014
Messages
25
Reaction score
0
First Language
Spanish
Primarily Uses
I made it work when the player steps on it, but it seems the barrel can't touch the switch even if its set to the above character's priority.. will check the variables guide then make a new post in here in case I have a question, which is most likely to happen :blush:
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Switch event has 3 pages. All set to Below Player. Also set all to THROUGH (I THINK this is needed in order for the crate event to be able to be pushed onto it - I have a feeling events don't look at the priority of other events - they just look at the THROUGH).
You will also need a way to make the crate appear in the same position each time you come back to the map (at least after it's been moved onto the switch). You can use my Remember Event Position for that, or have the 3rd page of the switch event have the CRATE graphic instead, and the second page of the crate event have NO graphic. That's probably the easier way.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top