Forged Alliance Forever Forged Alliance Forever Forums 2018-02-10T15:40:45+02:00 /feed.php?f=41&t=15890 2018-02-10T15:40:45+02:00 2018-02-10T15:40:45+02:00 /viewtopic.php?t=15890&p=160707#p160707 <![CDATA[Re: Execute sim code periodically]]> Statistics: Posted by C14 — 10 Feb 2018, 15:40


]]>
2018-02-10T14:50:49+02:00 2018-02-10T14:50:49+02:00 /viewtopic.php?t=15890&p=160706#p160706 <![CDATA[Re: Execute sim code periodically]]>
So you're doing it correctly

It's not a "real" new thread as the whole sim runs in a single thread on the cpu anyway.

Statistics: Posted by speed2 — 10 Feb 2018, 14:50


]]>
2018-02-10T14:45:59+02:00 2018-02-10T14:45:59+02:00 /viewtopic.php?t=15890&p=160705#p160705 <![CDATA[Execute sim code periodically]]>
what is the best way to execute some code that may change the sim periodically during a game,
say once a second or every n'th beat?
(context: I'd like to destroy units periodically that are outside of the map boundary)

Currently I am using ForkThread at the end of BeginSession in simInit.lua and WaitSeconds
in the thread function but altering the sim in another thread feels unsafe.
Is there a better way to execute code that affects the sim every n'th sim beat?
I've seen OnBeat and AddBeatFunction in ui\game\gamemain.lua but it seems to be only used in UI related stuff?

Statistics: Posted by C14 — 10 Feb 2018, 14:45


]]>