Any ideas to implement time-based queue priority?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
rita-
Prole
Posts: 4
Joined: Sat Aug 08, 2020 2:09 am

Any ideas to implement time-based queue priority?

Post 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. :(
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

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

Post 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).
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3549
Joined: Sun Oct 18, 2015 2:58 pm

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

Post by pgimeno »

You also have love.timer.getTime(), os.time() and require'socket'.gettime().
rita-
Prole
Posts: 4
Joined: Sat Aug 08, 2020 2:09 am

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

Post 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. :|
rita-
Prole
Posts: 4
Joined: Sat Aug 08, 2020 2:09 am

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

Post 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:
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 84 guests