Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Jasmine on Fri 26/03/2010 23:06:38

Title: Want player to be able to interrupt walking to object [SOLVED]
Post by: Jasmine on Fri 26/03/2010 23:06:38
I'm sure this has been asked before, but I can't figure out the keywords to find it, sorry!

Goal: click "look" on object -> character walks to object, but player can click somewhere else to stop walking to the object -> character says something about object.

Problem: if I use eBlock, the player can't interrupt the walk.  If I use eNoBlock, the script continues to run and the character says something before s/he reaches the object.  I'm sure the solution uses "character.Moving", but the only example I could find in the manual was:
cEgo.Walk(125, 40);
while (cEgo.Moving) Wait(1);

which won't work becuase the player can't do anything while waiting.
Title: Re: Want player to be able to interrupt walking to object
Post by: InCreator on Fri 26/03/2010 23:12:31
Force him to walk to the point he's at right now (thus-no walking) maybe?
Title: Re: Want player to be able to interrupt walking to object
Post by: Calin Leafshade on Fri 26/03/2010 23:21:38
what about something like:


while(cEgo.Moving && !mouse.IsButtonDown(eMouseLeft)) Wait(1);


Havent tested so i might have got some of the syntax wrong.

but the idea is that if you click the mouse the loop will exit.
Title: Re: Want player to be able to interrupt walking to object
Post by: Jasmine on Fri 26/03/2010 23:57:51
That does not appear to have any effect, Calin.  (The character talks and then walks.)  Leaving the part about the mouse button out causes it to mimic eBlock, so something about the mouse button part is ending the loop when it begins, instead of when the mouse is clicked.
Title: Re: Want player to be able to interrupt walking to object
Post by: Khris on Sat 27/03/2010 02:52:51
It's not supported by AGS natively, but you can use my module for that:
http://www.adventuregamestudio.co.uk/yabb/index.php?topic=36383.msg477380#msg477380
Title: Re: Want player to be able to interrupt walking to object [SOLVED]
Post by: Jasmine on Sun 28/03/2010 20:40:28
That looks to be exactly what I want, Khris, thanks!