finding when a character has reached their destination (SOLVED)

Started by EnterTheStory (aka tolworthy), Sun 09/12/2007 21:49:50

Previous topic - Next topic

EnterTheStory (aka tolworthy)

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.

Khris

That's what repeatedly_execute in the global script is for. It's called every frame.
Just put something like
Code: ags
  if (player.Moving) plmoving=true;
  else if (plmoving) {
    plmoving=false;
    // character just stopped moving
    DoStuff();
  }

inside and "bool plmoving;" directly above it.

EnterTheStory (aka tolworthy)

#2
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.

Scorpiorus

You can have the repeatedly execute event in the room as well:

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

Code: ags

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

Khris

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.

EnterTheStory (aka tolworthy)


SMF spam blocked by CleanTalk