Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: EnterTheStory (aka tolworthy) on Sun 09/12/2007 21:49:50

Title: finding when a character has reached their destination (SOLVED)
Post by: EnterTheStory (aka tolworthy) on Sun 09/12/2007 21:49:50
I'm sure I've read the answer here somewhere, but can't seem to find it...

The manual states, under "walk": "if you need to find out when the character has reached its destination, use the Moving property. See the variables section for more information."

Perhaps I'm being stupid here, but I couldn't find anything relevant in the manual, the fora, or the modules page. If I just put a loop that waits a frame and checks if ego is still moving, won't that hold up all the other scripts? Or should I make a "run always" function to work in the background? (If so, any tips?) Thanks for any pointers.
Title: Re: finding when a character has reached their destination
Post by: Khris on Sun 09/12/2007 21:54:43
That's what repeatedly_execute in the global script is for. It's called every frame.
Just put something like
  if (player.Moving) plmoving=true;
  else if (plmoving) {
    plmoving=false;
    // character just stopped moving
    DoStuff();
  }

inside and "bool plmoving;" directly above it.
Title: Re: finding when a character has reached their destination
Post by: EnterTheStory (aka tolworthy) on Sun 09/12/2007 22:07:16
Thanks. Does that mean I need to reference every possible function by name in the global script? I have a vague idea that I can just call "call hotspot[n].Interact" or something. But it's very late and it's been a long day. Maybe I should look at it again in the morning.
Title: Re: finding when a character has reached their destination
Post by: Scorpiorus on Sun 09/12/2007 22:24:49
You can have the repeatedly execute event in the room as well:

Follow: Room Interactions :: Repeatedly execute :: Run script


bool plmoving = false;

#sectionstart room_*  // DO NOT EDIT OR REMOVE THIS LINE
function room_*() {
  // script for Room: Repeatedly execute

    if (player.Moving) plmoving=true;
    else if (plmoving) {
        plmoving=false;
        // character just stopped moving
        DoStuff( );
    }
}
#sectionend room_*  // DO NOT EDIT OR REMOVE THIS LINE
Title: Re: finding when a character has reached their destination
Post by: Khris on Sun 09/12/2007 23:46:21
Quote from: tolworthy on Sun 09/12/2007 22:07:16Does that mean I need to reference every possible function by name in the global script? I have a vague idea that I can just call "call hotspot[n].Interact" or something.
Yes, it's called ".RunInteraction(mousemode)"; every clickable thing has it.
Depending on what exactly you want to achieve, using ProcessClick might work, too.
Title: Re: finding when a character has reached their destination
Post by: EnterTheStory (aka tolworthy) on Mon 10/12/2007 08:07:56
Thanks. I'll need to look into that.