Mine Cart Problem

Status
Not open for further replies.

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
Hi everyone,

Here is what I am doing. I got my hero climbing in to a mine cart to ride it. The controls mechanics are simple, if I push the joystick in the direction of the rails once, the car will roll down the track by it self. if I press the cancel button, (Brakes) the car will stop. When the car hit a switch Tile, it need to go left or right (Depending what direction the switch is set) I am using yanfly's RegionEvents Plug-in with a common event to control the car. here is the Code in the event:
◆Script:$gamePlayer.updateEncounterCount()
◆If:Boat is driven
◆Loop
◆If:SwitchTouch is OFF
◆If:Button [Down] is pressed down
◆Set Movement Route:Player (Wait)
: :◇Move Down

:Else
◆If:Button [Up] is pressed down
◆Set Movement Route:Player (Wait)
: :◇Move Up

:End

:End

:Else
◆If:SwitchTouch is ON
◆Jump to Label:Stop_Here
◆Break Loop

:Else
◆If:Button [Cancel] is pressed down
◆Jump to Label:Stop_Here
◆Break Loop

:End

:End

:End

:Repeat Above

:End
◆Label:Stop_Here

I tried to do loop, but I am having trouble interacting with the Switch Event.
Switch Event Code here:
◆If:Boat is driven
◆Control Switches:#0138 SwitchTouch = ON
◆If:Player is facing Left
◆Set Movement Route:Player (Wait)
: :◇Move Up

:Else
◆If:Player is facing Right
◆Set Movement Route:Player (Wait)
: :◇1 Step Backward

:Else
◆If:Player is facing Down
◆Set Movement Route:Player (Wait)
: :◇Move Right

:End

:End

:End

:End
Any Ideas what I can do to make this work?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Please give screenshots of your event pages - the content is not the entire event.
Things like triggers, page numbers and page ordering, conditions and more are affecting how the events react in such cases...
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
What is on page 2 of the switch event? Because that page will have priority and the first page never executed if you set the wrong conditions there
How exactly is the common event triggered? Can you give a link to the website of the plugin?
Because if I remember correctly, the region events of that plugin are only triggered if the player moves the party on the tile, not if the party is moved there by an automatic move route. Can you test that by moving the cart manually?

But your entire common event is strange - why do you check for button presses just to move the player into the direction of the button press, why don't you simply let the engine handle movement the regular way?
 

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
page 2 of the switch event as the same, but reverse controls.
http://yanfly.moe/2015/10/19/yep-17-region-events/

as i states in my first post, i wanted to move the car in the the direction when i push the directional button. ie push up makes the car facing up and roll automatically in that direction.​
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
as i states in my first post, i wanted to move the car in the the direction when i push the directional button. ie push up makes the car facing up and roll automatically in that direction.
But that is exactly how the default moving works, no need for an event to do that.
 

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
Any Idea how I should achieve this problem? a nice tutorial would be great!
 

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
Ok, it seems that my idea can not be done in this engine. I may have to come up another Idea for my mine area.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
Ok, it seems that my idea can not be done in this engine. I may have to come up another Idea for my mine area.
Anything can be done - but somehow you're not describing your idea correctly, because from what I understand, you don't need any event at all for that - going left when you press left, up when you press up is the default behavior of any movement on the map.

So please describe in detail what you want, and specifically what the difference is between your idea and the regular map movement.
 

Llareian

Jack of All Trades, Master of None
Veteran
Joined
Jan 26, 2017
Messages
604
Reaction score
1,421
First Language
English
Primarily Uses
RMMV
I think @MikeRPG33 wants the mine cart to start rolling in the direction of the button press, and KEEP moving in that direction without additional button presses until the player stops it. Correct?

I'm confused about how you have your event set up currently, so I'm afraid I'm not sure how to go about fixing it. But I would think you would want something along the lines of the following:

Since the trigger for the common event is the player stepping on a tile in the region, you should only need to check that the player is in the minecart, and what direction they are facing in order to start your move loop. Once in the loop, you should only need to check if they hit cancel, or they land on the switch tile. Then your switch tile needs an event with a touch trigger to handle changing the minecart direction.

Interestingly, this route would require two different regions/region-triggered common events, one for Up/Down track and one for Left/Right track. And handle the switch tiles entirely by their own events (don't make them part of either region).

If Boat is driven
If Player is facing Up
Loop
If (cancel button) is pressed down
Break Loop​
If (condition set by hitting switch tile)
(Jump to Label or Break Loop, as appropriate)​
Move Route: Player Wait
Move Up​
If Player is facing Down
Loop
If (cancel button) is pressed down
Break Loop​
If (condition set by hitting switch tile)
(Jump to Label or Break Loop, as appropriate)​
Move Route: Player Wait
Move Down​

(Sorry for the multiple edits. Preview was showing me different formatting than the final post and I was having trouble getting it right.)
 
Last edited:

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,533
First Language
English
Primarily Uses
RMMV

@MikeRPG33 , please avoid double posting, as it is against the forum rules. You can use the "Edit" function on your posts to add additional information you've forgotten or respond to multiple people. You can review our forum rules here. Thank you.



If Llareian is correct, then your problem is that you need some sort of loop for the move route. As is, you only have it to set 1 tile at a time. And since you don't know when the player will press stop, you can't set a move route for a certain length of time.

If you want to event this, I don't think you need the switches. I would just have it check if the "start" button is pressed, then in the if statement make a loop. The loop would move 1 tile then check for the cancel button. If the cancel button has been pressed, then it exits the loop, if not it repeats. I honestly don't know if this is the best way or not without testing, but it's what I would try first.

edit: Maybe something like this? I've never really utilized the break loop and I'm still on my first cup of coffee so this may not work. I've only used labels and jump to label for looping.

loop.png
 
Last edited:

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
ok tried your suggestions and did not work. Here is what i set up.

01.png 02.png 03.png 04.png 05.png 06.png 07.png
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,533
First Language
English
Primarily Uses
RMMV
I'm about to go out the door, so I can't test right now. To me, it looks like you are seriously overcomplicating it. And again, I'll have to play a bit to test exactly how the break loop functions, but I'm not understanding why you have break loops inside loops with nothing else happening. But, perhaps I need to look more closely.

If this has not been solved later when I'm home, I'll give it a go and see if I can get something to work.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
no, it won't work - because you messed up the loop and break loop conditions.
For example, in your very first picture, you probably wanted the set move route to continue until the button is pressed - that means the set move route needs to be outside the conditional branch where you break loop, but inside the loop.

In your second picture, you have a double break loop and conditions after the break loop - but the break loop command already stopped the loop and continued after the repeat.

And so on - I suggest next time, you design the logic in a flow chart before placing the commands, that usually prevents such mixups.
 

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
ok i know what you mean, i edited the script your suggestion and it works, until it hit the end of the vertical track. and it freezes.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
update your screenshots to the current version and we can check again - the comments above where only examples, I didn't check for every error.
 

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
here the latest script for the car. I decided of using the switch to change direction of the car on the switch track, I decided to go for the gates instead.
 

Attachments

MikeRPG33

Veteran
Veteran
Joined
Jun 8, 2015
Messages
49
Reaction score
1
First Language
English
Primarily Uses
To let you guys know, I finally fixed the problem. On the corners and switches you need to add a regular event, to tell the player what direction you need to go on what you direction you are facing. You also need to make a variable in your position that equals to the region ID. in this case its Region ID #3. this tells the loop when to break. (See pic for more Detail)
03.png 04.png 05.png
 

mlogan

Global Moderators
Global Mod
Joined
Mar 18, 2012
Messages
15,354
Reaction score
8,533
First Language
English
Primarily Uses
RMMV
I tried sending this reply last night, but got blocked by the error message everyone was experiencing. (Yay for fixing urls!)

So, I played around just a little bit and got a small sample working. Of course, to implement it fully, you'd need to expand the system a bit more. But, I really feel like you are overcomplicating things. It's easy to do with events, especially systems like this.

The first thing I did was remove the vehicle aspect. I am using a car and roads in my test. I made a car event. When the player interacts with it, it changes the character's graphic to the car graphic. I used a switch to "erase" the car event's graphic. Normally you would use a self-switch to do this, but I used a switch, with the thought that you might need to turn it on again later, or leave it off.


Next I made only one event to trigger the action. You would need to put these more isolated events in spots where the minecart would start or stop, but I just did this one to test.

For the actual movement, I only tested one direction, but it works. The biggest issue is that you have to more hold the Esc/cancel button down instead of simply pushing it. Because of the way MV loops through events, I think this is going to be necessary no matter how you event it, and perhaps was part of your problem. But essentially, if the key press is not occurring at the exact split second (literally) that the program reads that "If" statement, it won't register, thus having to hold it down. I'm not sure if there is a solution, of if you would need to indicate that to the player somehow to hold down the cancel button until it stops.


I'm not sure I would use the region script the way you have - to process a common event each step of the way. If you set up your event similar to mine, the action will keep looping until the escape is pressed, even with that one event. I would perhaps instead use the region script around the roads/tracks with an impassible setting, to keep the cart on the tracks.

edit: I see you posted as I was finishing up my post. I'm glad you got something working.
 
Status
Not open for further replies.

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

Latest Threads

Latest Profile Posts

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.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top