Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Example of Wait before event?

Author
Message
hoyoyo80
7
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 7th Nov 2016 23:08
Hi all..

Can somebody give me example on how to wait a few second before executing event inside a function?

Something like:

function

Wait 3 seconds then run event

endfunction

Help is greaty appreciated Thanks
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Nov 2016 11:48 Edited at: 8th Nov 2016 11:49
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hoyoyo80
7
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 8th Nov 2016 18:27
Hi Batvink

Thanks for the code.It work for me but is there anyway we can time some event without affecting the main loop? Example,AI is stop and think but player can freely move doing the period.

Thanks
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Nov 2016 19:16
The better way to do it is to direct your AI with variables in the main loop. In its simplest form, you have a series of IF statements that get processed every cycle...



Now you can control some of these flags with a timer. Here the enemy wakes up 10 seconds into the game...


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hoyoyo80
7
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 9th Nov 2016 04:28
Thanks BatVink for the ideas

It work now within function by checking if time#=0 then assign to timer()+time in second,pass to function and compare with timer(). Thanks
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 9th Nov 2016 21:31
If you have multiple timed events, I suggest assigning timer() to a variable each loop and using that so you're not making multiple system calls.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
hoyoyo80
7
Years of Service
User Offline
Joined: 11th May 2016
Location:
Posted: 11th Nov 2016 04:10
Thanks phaelax for responding...im not very good at programming but i try to learn.

But there are a few thing that is hard for me like timer and random.

If they are placed in main loop than the variable from timer and random will be replace/reassign each loop.I really dont have a good grasp of this concept yet.

Thanks

Login to post a reply

Server time is: 2024-03-29 14:38:02
Your offset time is: 2024-03-29 14:38:02