I wanna implement a time-based priority for the queue containing actions of my game's roles.
It is necessary for the logic running.
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.
Any ideas to implement time-based queue priority?
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Any ideas to implement time-based queue priority?
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 True 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.
Re: Any ideas to implement time-based queue priority?
You also have love.timer.getTime(), os.time() and require'socket'.gettime().
Re: Any ideas to implement time-based queue priority?
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
os.time() is totally not right, so i get stuck.
Re: Any ideas to implement time-based queue priority?
thank you so much!! now i have worked it out
Who is online
Users browsing this forum: No registered users and 3 guests