
2


You can either use coroutines or a timer pattern, see the sample I posted on another thread:
-- global time time_t=0 actors={} for i=1,32 do add(actors,{t=rnd(90),visible_t=0,x=rnd(128),y=rnd(128)}) end function _update() time_t+=1 for a in all(actors) do -- timer elapsed? if a.t<time_t then -- visible for some time a.visible_t=time_t+rnd(30) -- "think" time a.t=a.visible_t+rnd(90) end end end function _draw() cls() for a in all(actors) do if a.visible_t>time_t then print("-o-",a.x,a.y,7) else print("---",a.x,a.y,1) end end end |

3


Each update is 1/30th of a second (unless you use _update60(), in which case it's 1/60th of a second). So you can just make a counter that counts down from however many frames you want to delay, then when it gets to 0, do whatever is next. That's the "swing a big, fat hammer at it" approach.
The "use a scalpel" approach is to use "coroutines" to delay whatever action should happen next. But that's a much longer answer.
EDIT: Or just follow the example that @freds72 helpfully posted while I was typing my reply. :D
[Please log in to post a comment]