Event Movement Timing

Internetomancer

Veteran
Veteran
Joined
Nov 16, 2015
Messages
57
Reaction score
26
First Language
English
Primarily Uses
Hi, I'm trying to have an event move, and then run a script based on its new position, which can tell it to move again... and so on...


I'm having problems though because I don't know how to tell an event to run a script after it has moved.  Instead it tends queues up the movement, and then runs the script over and over again, locking up the game.


I've been digging through the rpg_objects code for hours, but I think I'm just missing something simple.


Any help would be desperately appreciated!
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Are you doing this through event commands or trying to modify scripts to do it?  Please show a screenshot of what you've got so far as your description doesn't really give us much to go on.


Could be as simple as setting the movement route to 'wait for completion' before running the script.
 

Internetomancer

Veteran
Veteran
Joined
Nov 16, 2015
Messages
57
Reaction score
26
First Language
English
Primarily Uses
Hi Shaz,


Thanks for replying so fast.  I've been trying both.


Right now, I have a command, telling my event to move, and then an script deciding where it should move from there.


Set Movement Route : This Event (Wait)


 :<>Move Right.


Which works.


Then I wrote a script that tells it where to move next, based on its surroundings.


That also works.


My problem is I want to run the script again, after the event gets there.  And it locks up.


I've set "wait for completion" in both my event command and my script.  But the code still locks up.  I guess because my code doesn't know how to wait, even though the event knows to wait...  Or something?  I don't know...
 
Last edited by a moderator:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Can you please show a screenshot?  And if you wrote a script, include that too (in spoilers and code tags)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
It sounds as if you made the script call at the wrong position in the event code - that is why we need a screenshot to see exactly what you placed where.
 

Internetomancer

Veteran
Veteran
Joined
Nov 16, 2015
Messages
57
Reaction score
26
First Language
English
Primarily Uses
Hi-- I woke up this morning determined and finally got it.  Sorry I couldn't explain better.


I was just trying to make a train move on some tracks.  Which is all script right now, and not any kind of event (although I tried using events).


What I needed to do was change Game_Event.prototype.update() 


Which is the code that calls all the movement codes.  When I added my little script to that, it worked fine.


If this continues to work fine, I'll try to build a plugin.


Thanks again for your time.
 

Code:
INT.Game_Event_update = Game_Event.prototype.update;
Game_Event.prototype.update = function() {
    INT.Game_Event_update.call(this);
    if (this._eventData.note=="train" && DataManager.moving==true) this.CheckTracks();
};

Game_Event.prototype.CheckTracks = function() {        
        var idlist = $gameMap.eventsXy(this.x, this.y);
            for (var i=0; i<idlist.length; i++) {
                if (idlist[i]._eventData.note=="track") {
                    var track= idlist[i]._eventData.name;
                    var d1= ""
                    var d2= ""
                    var mine_dir=this.direction()
                    
                    for (var j = 0; j< track.length; j++) {
                        d1=GetDir(track[j]);
                        j++;
                        d2=GetDir(track[j]); 
                       
                        if (10 - d1 == this.direction())  {
                            this.setDirection(d2)
                            this.MoveForward()
                            
                        }
                        if (10 - d2 == this.direction())  {
                            /*this.moveStraight(GetDir(d1));*/
                            this.setDirection(d1)
                            this.MoveForward()                                        
                        }
                    }
                }
            }
}
    

        
this_event.moveForward();
        this.forceMoveRoute({
            list:
            [
            {
            code: 12,
            indent: null,
            parameters:[]
            }
            ,{
            code: 0,
            indent: null,
            parameters:[]
            }
            ]
            ,
            repeat:false,
            skippable:false,
            wait:true
            })
    }



function GetDir(dir) {
if (dir == "W") return 4
if (dir == "N") return 8
if (dir == "S") return 2
if (dir == "E") return 6
}
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
@Internetomancer and where is the screenshot of the event?


And by the way, why a script? why not simply use the existing functions provided by the events?
 

Internetomancer

Veteran
Veteran
Joined
Nov 16, 2015
Messages
57
Reaction score
26
First Language
English
Primarily Uses
There's not much of an event anymore...


The script is so the event can interact with other events.  In this case a train interacting with train tracks.  There's probably some easier ways to do it, but I don't know any method using just events.

screen.png
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,367
Reaction score
7,676
First Language
German
Primarily Uses
RMMV
I suggest you check the area called "autonomous movement" between the image and the content. Those movement controls are independent of the event content - usually that allows a villager to move around while still starting a conversation on action button.


Interaction between events should always be controlled and checked from the outside, not from the events themselves. There are a lot of reasons for that (including to prevent mistiming), some of them you can read about in the bughunting tutorial I wrote (link in my signature).


There are different ways to control an events movement, and you need to use them all depending on what exactly the specific case is - for example there are scripts that place barriers only for events on the map, and you can let the event move randomly within those areas while the player can still go everywhere.


Or you can preprogram the move routes, or use a parallel process to check for positions, or several other options.


Which one is best depends on the exact situation - a tracked train would use a different method than a randomly wandering animal for optimal effects
 

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

Latest Threads

Latest Posts

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,085
Members
137,584
Latest member
Faustus2501
Top