mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-23 05:00:55 +01:00
Add a SS13.check_tick lua function (#89081)
## About The Pull Request This adds a new function for Lua scripts: `SS13.check_tick()` - it acts pretty much exactly like the `CHECK_TICK` macro in DM. It accepts a single argument, a boolean, which if true - it will act like `CHECK_TICK_HIGH_PRIORITY` instead. ## Why It's Good For The Game this function is a repeated code pattern in lua scripts, so having it in the SS13 lua library is useful. ## Changelog 🆑 admin: Added a new function in Lua scripting, SS13.check_tick, to avoid causing too much lag during loops and such. /🆑
This commit is contained in:
@@ -39,6 +39,13 @@ function SS13.is_valid(datum)
|
||||
return dm.is_valid_ref(datum) and not datum.gc_destroyed
|
||||
end
|
||||
|
||||
function SS13.check_tick(high_priority)
|
||||
local tick_limit = if high_priority then 95 else dm.global_vars.Master.current_ticklimit
|
||||
if dm.world.tick_usage > tick_limit then
|
||||
sleep()
|
||||
end
|
||||
end
|
||||
|
||||
function SS13.await(thing_to_call, proc_to_call, ...)
|
||||
if not SS13.istype(thing_to_call, "/datum") then
|
||||
thing_to_call = SS13.global_proc
|
||||
|
||||
Reference in New Issue
Block a user