A simpler way to move.

I’ve been doing a bit of work with the Move command lately.  One of the challenges of building a real script engine into a system that’s supposed to behave like RPG Maker is finding a way to translate all the event commands into scripts.  Most of them are easy, but some are kind of challenging, like the Move command.  It represents each move operation as a number, unless it’s one of the commands that takes parameters, like “Play Sound” or “Switch On”, in which case things get more complicated.  But one of my goals for the script system is to make each command something that can be written and understood in a normal script.  You can’t do that with a string of numbers.

The obvious way to handle this is to have the script engine itself take care of moving. So I had the project importer translate the numbers into words, and you’d end up with something that looks like this: “Up; Left; Left; Left; Down; Down;”

Then I took a look at the move scripts it was creating, and some of them were huge!  For particularly long movements, they could get up to 500 characters or more.  That makes the script difficult to read and difficult to understand, especially at a glance.  For example, how many times is the character going to move left when the following event command gets run?

If you have to count one by one, it’s too complicated.  So I reworked the move script generation code.  When this gets processed, the output will look like “Up; Right(2); Up(2); Left(13); Down(2);”  Any command that doesn’t already require parameters can take an optional number parameter that describes how many times to repeat it.  This should make long move scripts a lot easier to understand.

2 Responses to “A simpler way to move.”

  1. DJC says:

    This is a great idea that will make move events far more legible and easy to construct. Many a time I had to go back and count to double-check a movement or see where the event ends up.

    Of course, the ultimate solution is path finding and a function that simply moves an event to a set of coordinates, but that’s a bit more difficult to implement, and you still need the move event for RPG Maker compatibility.

  2. Yeah, I’ve been thinking about that, and I’ll probably end up implementing a “Generate Path” command that inputs two points (or a map object and a destination point) and uses a pathfinding algorithm to create a path string.

    Problem is, path generation can only include the basic direction movement commands. The rest of the move commands would have to be added manually. So I’ll probably also make the pathfinding algorithm accessible from within the path editor so you can autogenerate a path and then customize it. 🙂