Moving Platforms Without Script?

Is there any way to make moving platform puzzles without a script, or at least without needing a "pixel movement" script like Victor Engine's moving platforms script requires? The pixel movement script he uses screws up collision in my game.
If you use events as platforms you can move them and make the player able to walk over them. I have to say that you are not giving many informations here.

I have thought of a couple of ways of doing it using events - and I am talking about ways that use ONLY events - but they are very complex. Before going deeper - since it takes quite a lot of time - I'd like to know something more about what you are trying to do and HOW you want it to work.
NVM, I didn't see it was ace
If you use events as platforms you can move them and make the player able to walk over them. I have to say that you are not giving many informations here.

I have thought of a couple of ways of doing it using events - and I am talking about ways that use ONLY events - but they are very complex. Before going deeper - since it takes quite a lot of time - I'd like to know something more about what you are trying to do and HOW you want it to work.

Here's the part of Victor's script I want to recreate (I already have a jumping script in mind):

You could use switches and wait commands to make tiles appear and Disappear but they wouldn't have smooth movement like the ones in the video. For example: 2 tiles next to each other, you jump on one, then walk to the second. And then the first disappears, and as that happens another tile will appear next to the tile you are currently on within jump-able distance. The loop that to your hearts content. But I don't think that's what you want.
You could use switches and wait commands to make tiles appear and Disappear
This might work but if I got it right the OP is looking for a moving platform and not a disappearing one. Well, it can be done using events, you don't need a script for that. The only problem is that the event itself, as I said, is quite complex.

Spoiler: Event setup
To configure your event you have to keep a couple of things in mind:
  • How many events you need
  • What these events do
  • How to move them
  • How to move the player once it steps on the event
  • Which actions the player can/cannot do once on the platform
Spoiler: How many events?
First of all let's see how many events you need. I'd say you need one plus the number of platforms you want to use, that is not the bare minimum but I am quite sure is the easiest way around. You could have just platforms and it could be still fine...however your event would be much more complex.
Spoiler: What do they do?
I'd say platform events should trigger once the player steps on them (Below Player + Player Touch) and they only activate a switch (the same switch for all of them, not a self switch.)

The other event (it needs no graphic at all but if you have an event that does nothing you can just use that one to avoid adding more to your map) should move these events. You can simply decide a path for them and then move them, just remember to move them all and only set the event command to wait for the last one who's being moved.
Spoiler: How to move them?
The main problem about this is that you really want that event to run more than once so that it can check if the switch is active (in which case it should move the player as well). For this reason it is better if you put those movements in conditional branches to check if the events can actually move in that direction or if they have to move in the opposite direction (or just another direction).
Spoiler: How to move the player?
Once the player steps on one of those events (how that is done depends on the jumping script) you trigger the switch. If the switch is active you should add an extra movement for the player on every branch related to those platform events in your other event.

Here is an example (PSEUDOCODE):
Code:
if (EVENT_1_CAN_MOVE_RIGHT)
  if (PLAYER_ON_PLATFORM)
    PLAYER.MOVE_RIGHT
  end
  EVENT_1.MOVE_RIGHT
else
  if (PLAYER_ON_PLATFORM)
    PLAYER.MOVE_LEFT
  end
  EVENT_1.MOVE_LEFT
end
if (EVENT_2_CAN_MOVE_RIGHT)
  if (PLAYER_ON_PLATFORM)
    PLAYER.MOVE_RIGHT
  end
  EVENT_2.MOVE_RIGHT
else
  if (PLAYER_ON_PLATFORM)
    PLAYER.MOVE_LEFT
  end
  EVENT_2.MOVE_LEFT
  wait #This only goes here if you want them to move smoothy
end
I put the wait after event 2 because in my exaple I only had 2 events. You can have more, just remember to put the wait after your last event.

NOTE: since in your event commands your wait is included in a move route command I put the conditional branch for player before the one for the event. If you do the other way around and add the wait command only to the branch refering to game player you can have many issues because that branch is not guaranteed to run.
Spoiler: What can the player do once on the platform?
This is a tough question. Probably the worst one here. If you want to move the player you have to either activate "Through" option for the player together with the switch that tells when he is on a platform or you can have your tiles passable. Activating the "Through" option is probably the best idea IF and ONLY IF you turn it off at the end of every step. Otherwse the player can just move where he is not supposed to.

I'd say you should deactivate that option before the move route including the wait option. That's because being your event a parallel process the player can be fast enough to just move once the event ends and you are screwed. I am not 100% sure something like this can happen and chances of it actually happening are very low, but there is a high chance it is possible (not that it will happen, just it being possible) so avoiding it is better than being bitten later on, isn't it?

I tried to use spoilers to avoid the evil wall of text, I hope I achieved what I was trying to and I hope this is useful to you.

Keep in mind that this is not the only way of doing this. There are other ways if you want to add a few script calls to your event rather than just using event commands.
Spoiler: Other ways to do it
Another way of doing it is to store platform direction when checking if movement is possible and then check passage only for that direction. When that is no longer possible you can change its direction value.

What's good about this?
  • The method to check passage is already known to Game_CharacterBase (which is the superclass for events). This means you can use it freely without using any script.
  • Having a direction stored means saving conditional branches. You can just use the "move_straight(direction)" method (also known to Game_CharacterBase) for both event and player. Just keep in mind that you have a different direction for each platform so store them in different variables. The player, on the other side, can use the same variable as the plaform he is on.
  • You can store an hash of directions in a variable and access those directions using event id as the key. I do not recommend this option but if you are using a lot of variables and do not want to use too many for those directions you can do that. Just keep in mind that even if you put them in a single variable you still use memory so you have no performance benefits at all. On the contrary, it will actually be slower (I don't think you will ever notice it but it will).
What's bad about it? Honestly nothing. Using script calls rather than using event commands is thousand times better. Of course you have to know what to write there so that can be a downside.
Could you give a more detailed example of how to do the second one? I don't quite get script calls.
Of course I can give you few examples. Let's start with the one to check your passage. You can do it in two different ways:
1) you can check if there is a wall,
2) you can check something else if you want your event only to move on few tiles.

Spoiler: If you are checking walls
As I said the Game_CharacterBase class already has a method to check if a certain tile is passable. That said method is called "passable?". You use it this way:
Code:
e = your_event_goes_here
new_dir = (e.passable?(e.x, e.y, e.direction) ? e.direction : e.reverse_dir(e.direction))
e.move_straight(new_dir)

# This moves the event in the specified direction (or the opposite).
# To move the player then you add the following

$game_player.move_straight(new_dir) if (your_switch_goes_here)
# Since switches are booleans you only have to type your switch name.
# There is no need to add conditions. The switch itself is a condition.
# A switch name is $game_switches[id].

# Other events move the same way as the previous one.
# Please note that I didn't add any wait here so they move simultaneously.

# When you moved everything you had to you can add this (ONLY after you moved everything)

Fiber.yield while last_event_you_moved_goes_here.moving?

Of course the previous way around only tells you if the tile is passable and does not give you the freedom to move things on the water or to stop things before they hit a wall.

For that purpose I mentioned the other way.

Spoiler: If you are checking something else
Here I will use regions to draw my path so first of all you need to select a region id to draw your path. Once you have selected your region id (in my example I'll be using id 63) you can use this in a script call:
Code:
e = your_event_goes_here
x_new = $game_map.round_x_with_direction(e.x, e.direction)
y_new = $game_map.round_y_with_direction(e.y, e.direction)
new_dir = ($game_map.region_id(x_new, y_new) == 63 ? e.direction : e.reverse_dir(e.direction))
The part that moves $game_player is exactly the same as before so I didn't add that. The same goes for your wait command at the end.

Now a few words of advice before you start using this (if you want to do it this way instead of using event commands):
  • First of all you have to know that you should refer to events using $game_map.events[id].
  • Then you have to remember that when you use your wait command you have to add it using the last event you moved - as I wrote - and not $game_player. That's because if the player is not moving using it will run it many many times. This also means you should better put your last event movement after you move $game_player or the player won't be able to get off before a new movement will start.
  • This code only helps you moving events if they follow a straight path. The moment you want them to follow different paths it is gonna be quite messy and way more complex. This does not cover that part. If you want to do that you can use a variable to store your starting point before every movement -> check if there is any other square around where you can move -> if there is override that variable with your current event position then move, if not then override that variable with your current event position then move to the previous spot (this requires a temporary variable). It is incredibly messy and only a couple of events can be moved within a single script call. That does not mean you cannot move more than two events but you need different script calls.
  • REMEMBER THAT "Fiber.yield"! You really don't want to forget this or the event will run many many times without waiting. There is no need to run something so many times: it slows your game down and it can cause troubles.
Well, that's all - at least I cannot think of anything else that could be helpful to you right now. I think you have everything you know to do this.

The only thing I can tell you is that you can actually add a couple of constants to your scripts (just a blank one with constants) to use a shortened version of your script call. What I mean is that creating an hash with your map id as key containing your platform events for each map is a good idea.

Spoiler: How to create your hash
First of all open your script editor F11 and go below materials. Create a new script and paste this:
Code:
module HMP
  PLATFORMS = {
    map_id_goes_here => [event_id, another_event_id, one_more_event_id],
    another_map_id_here => [add_more_events, as_long_as_they, are_separated_by_commas],
  }; # don't forget the comma at the end of each line if you want to add more!
end
Of course you can edit that hash and add anything you need. Now you can access your moving platforms all together. Which benefits do you get from doind this?

Well, without knowing too many details just know that everything you have to do to move your platforms once you do this is add this single script call:
Code:
HMP::PLATFORMS[$game_map.map_id].each do |id|
  e = $game_map.event[id]
  x_new = $game_map.round_x_with_direction(e.x, e.direction)
  y_new = $game_map.round_y_with_direction(e.y, e.direction)
  new_dir = ($game_map.region_id(x_new, y_new) == 63 ? e.direction : e.reverse_dir(e.direction))
  $game_player.move_straight(new_dir) if (your_switch_goes_here)
  $game_map.events[id].move_straight(new_dir)
end
hash_last_index = HMP::PLATFORMS[$game_map.map_id].length - 1
Fiber.yield while $game_map.events[HMP::PLATFORMS[$game_map.map_id][hash_last_index]
This will move EVERYTHING has to be moved (platforms, player, just everything). In this example I used regions to draw a path and I used region 63 as in the previous example.

Keep in mind that I am writing this from mobile so while I am confident in my coding skills I have no way to test it and typos are always around. I hope there won't be any but after typing this for more than 1 hour I cannot guarantee that.

I just hope you got a grasp on how to do it and I hope you can use it and adapt to your game to achieve what you are trying to.
Er... when I said I didn't quite get script calls, what I meant was that 90% of what you just posted seemed like an entirely foreign language to me and I was hoping you would explain it to me like you would to a complete idiot. XD
I am sorry, I don't want to be rude here but I really don't know how to say this so I'll try to be as honest as possible while trying to not be rude. Please forgive me if I fail to achieve that; I am not that good with words.

First of all if 90% of what I said sounds like a foreign language to you that's because you don't know ruby or - probably - any object oriented programming language at all.

What I can tell is that script calls are small pieces of code written in ruby. Ruby is a programming language. If you want more informations about ruby in general you can find them on the wikipedia page and if you want to know more about its syntax you can press F1 on your RPG Maker VX Ace and read about it there.

Spoiler: Why do we use script calls
The main reason behind the usage of script calls is freedom. Script calls (event commands 3rd page) allow you to write anything you want as long as its syntax is correct and then execute what you wrote when you run your event.

Since you are the one writing the code you are free to use only the parts you need while avoid using those parts you don't need. Event commands are coded too but sometimes they only do half what you want them to do, sometimes they do a few things you don't want them to do. Writing your own code allows you to take those parts you want them to do, remove parts you don't need and add parts you want to add.

Of course RPG Maker VX Ace code is big. Event commands are just a very small part of what is written in the code itself and they do not cover every single possibility. That does not necessarly mean that doing something not covered by event commands is impossible. Sometimes the code contains exactly what you are looking for but that thing is just not an option you can pick because there is no event command for that.

Do you want an example of what I mean? Let's say I want to use a graphic transition when moving from one place to another and I want it to be like the ones you have then entering battle. You have no event command for that, have you? But you know for sure that they are possible...I mean, you have them for battles so there must be some way of doing it if the engine does it.
Well, you know what? There is a way of doing that. There is no event command for that but the engine itself is abl to do it because it is written somewhere. So how can you use that? Simple enough: you use a script call, you add a little code containing the part you need and then you are able to do it anywhere.

Of course to do something like this you have to search inside the code and see which part of it does what you need.

That's not the only reason to use script calls. You can still se them to create something entirely new (like a different window layout or a completely new sprite that rotates constantly). If you know enough about ruby and RPG Maker VX Ace code you can do anything you want.

Long story short: script calls are one way of using your own code without having to add scripts. They are a way to bend the engine to your will even when you want to do things the engine is not supposed to do.

Once you become familiar with coding you will definitely find script calls a much better alternative to event commands and you will start using them for things covered by event commands too. Why is that so? Because that way you are in total control. You do not have anything you don't want to and you are free to use exactly what you want to use.

That covers what a script call is. Now let me spend a few words about what you need to know to understand a script call.

Spoiler: Why script calls are not easy to understand
While I could explain you what the syntax I used means that would take a very long time and would prepare the ground for new questions. The more you learn, the more you need to know.

While the engine itself contains information about ruby's syntax I have read them once and I think they are not "newbie friendly". In my opinion they are fine if you know how object oriented programming - or at least programming - works but if you don't then they are not that easy to understand.

On the top of it to understand how various classes and methods work you have to read the code itself to see which method does what and to see how they interact with each other. Of course you can press F11 and read that much there once you understood ruby syntax but once again that is not a simple task if you know nothing about programming. There are also few classes not displayed so you have to look how they work by presing F1 and looking for them in the index.

Before deciding how to judge my answer I would recommend you to follow the steps I mentioned above and see actually how much there is to learn. This is not to demoralize you, is just to give you a vague idea of how vast this topic is. There is a reason if there are teachers being paid to teach these things and that reason is: because you need a lot of time to teach them.

That said, if after that you are still willing to learn how script calls work I'd be glad to give you a few links to tutorials and documentation. If you get discouraged and decide that it is not what you want I will still be glad to help you with my coding skills but then you should just accept the fact that what I wrote works that way because "it does". The only thing you can do is replace what has to be replaced and that's all.

In this case I posted one way of doing it without having to rely on script calls, and that is becuase I know script calls are not easy matter and I wanted to be as helpful as possible. If you find using script calls I wrote too hard you can always rely on what I wrote about not using them. You achieve the same thing. It is just on another level of freedom.

I hope I achieved my goal of not being rude while giving you at least a vague idea of what a script call is. About ruby and its syntax there is nothing we can do, you have to learn how the language work before you learn how to use it properly.

Original thread: https://forums.rpgmakerweb.com/threads/moving-platforms-without-script.96830/