-
-
Notifications
You must be signed in to change notification settings - Fork 106
add priority_queue module #580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Ворованный скрипт, переработанный с помощью нейросети. |
It's not stealing if there's almost nothing left of the original. |
res/modules/tick_timer.lua
Outdated
print("Timer error (" .. timer.name .. "): " .. err) | ||
-- Optionally log the error to a file or system logger here | ||
-- Optionally re-raise the error if you want to stop execution | ||
-- error("Timer callback failed: " .. err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can't decide what to do when callback throws error
In any case, the complete misunderstanding of the engine events system, metamethods without metatables (is it even tested?), random indentation in different functions (like lazy copy-pasted), useless AI-generated comments completely undermines the credibility of the code work without Lua autotests (dev/tests) |
it's mine dumb comments ;( sorry for that. But that's what code review is for, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to leave only PriorityQueue for now, and I'll create a PR for the correctly integrated scheduler today
Ok. I recommend using update_front_priority to efficiently change the priority of the smallest element in the queue. And it might be worth creating a separate list for timers that are called every tick, as the queue isn't very efficient in this case. |
And also item must have an "id" field. |
Usage example:
It turned out that on_world_tick hardly works in modules (It only works if the module is exported to world.lua that does not yet have on_world_tick.), so users (for now) will have to call Timer.tick() manually as in the example, and also ensure that Timer.tick() is called exactly once per tick (using the global flag Timer.b_acquired_by_some_script).