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:
Lucy
2025-01-22 16:46:14 -08:00
committed by GitHub
parent f10f6c30e3
commit b53ced4e75
+7
View File
@@ -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