Attempting to move events via script

pizzadog

Warper
Member
Joined
Dec 11, 2016
Messages
1
Reaction score
0
First Language
English
Primarily Uses
Hi! I'm new to RPGMV and JS but not to programming in general - lots of experience in Python and other languages. Right now I'm trying to make a script that controls the movement of several events in a city - namely, Cars. I have several of the basics hammered out (how to make them move offscreen, how the sprites are going to look, etc) but plugging it all into RPGMV is giving me some trouble.

To familiarize myself first I'm just trying to get the script to move the sprite across the screen a small distance.

 

var CarMove = Carmove || {};


CarMove.parameters = PluginManager.parameters('CarMove');


for(var x = 0; x < 10; x++){
    gameMap.event(022).moveStraight(2);
}

This is my attempt so far and it does nothing. I'm attemping to move event #022 down a few steps. Could someone explain where I'm going wrong? I apologize in advance if this is a pitiful question.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,108
Reaction score
13,713
First Language
English
Primarily Uses
RMMV
You have to give the event a proper move route.  This causes it to execute a movement and wait for it to be complete before it does the next one.


Also, you've got some syntax errors / typos in there.


$gameMap, not gameMap


event(22), not event(022)


but at best, I'd expect it to move once, because you're not waiting for the movement to complete.


This is how you create a move route via script in Ace:





You would need to figure out the MV equivalent.  A good starting point is to create the move route in an event, save it, then go take a look at the Map###.json file to see what the commands and properties are, and then use script to recreate it.


tbh I think doing it via script is more trouble than its worth, and unless it's exactly the same move route applied to a large number of events, I'd just event it.  You can use the Autonomous Movement set to Custom (to the right of the event graphic) to set up automatic movement.  You don't need to set the event trigger to Parallel Process for this to work - autonomous movement is independent of the trigger, so just leave it as Action Button (or Event Touch if you want the cars to be able to hit the player)
 
Last edited by a moderator:

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

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,040
Messages
1,018,470
Members
137,821
Latest member
Capterson
Top