Page 1 of 1

Any ideas to implement time-based queue priority?

Posted: Tue Aug 18, 2020 9:49 am
by rita-
I wanna implement a time-based priority for the queue containing actions of my game's roles. :crazy:

It is necessary for the logic running. :o:

My idea is use time mark to sort the queue.

But I am confused, in LÖVE we could only get delta time between last 2 frames in love.update(), and then I totally can't think of a clear solution. :(

Re: Any ideas to implement time-based queue priority?

Posted: Tue Aug 18, 2020 11:38 am
by zorg
You can store accumulated dt values over multiple frames in a table, and you can sort using those values, for instance (e.g. comparing them to already known time intervals or something, i'm not 100% sure i get what you'd like to do).

Re: Any ideas to implement time-based queue priority?

Posted: Tue Aug 18, 2020 12:21 pm
by pgimeno
You also have love.timer.getTime(), os.time() and require'socket'.gettime().

Re: Any ideas to implement time-based queue priority?

Posted: Tue Aug 18, 2020 2:28 pm
by rita-
zorg wrote: Tue Aug 18, 2020 11:38 am You can store accumulated dt values over multiple frames in a table, and you can sort using those values, for instance (e.g. comparing them to already known time intervals or something, i'm not 100% sure i get what you'd like to do).
thanks for reply!

^^ the thing i would like to do is like a battle recorder? (actually not, maybe a byproduct
it seems like:

23:03:10 you dealt 13 magical damage to slime
23:03:33 slime granted a mana shield
23:09:20 a slime was spawned nearby
23:09:20 a slime was spawned nearby

like these lines, every *action* has a specified occurrence time.

in a frame, there are many actions that will happen, i would like to point out which happened in advance and which happened afterwards, since love.timer.step() returns an interval time.

i try to solve this by using an act function with an argument time to decide queue priority

act(actionName, time) (a member function)

but i don't know where the time is from :shock:

os.time() is totally not right, so i get stuck. :|

Re: Any ideas to implement time-based queue priority?

Posted: Tue Aug 18, 2020 4:24 pm
by rita-
zorg wrote: Tue Aug 18, 2020 11:38 am You can store accumulated dt values over multiple frames in a table, and you can sort using those values, for instance (e.g. comparing them to already known time intervals or something, i'm not 100% sure i get what you'd like to do).
thank you so much!! now i have worked it out :ultrahappy: