mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 10:11:09 +00:00
Replaces Auxlua with the byondapi-based Dreamluau (#84810)
## About The Pull Request Ever since byondapi went stable, I've been meaning to create a replacement lua library that uses it instead of the auxtools-based auxlua. After so many months, I've finally got the code just about into a position where it's ready for a PR. [Click here](https://hackmd.io/@aloZJicNQrmfYgykhfFwAQ/BySAS18u0) for a guide to rewriting auxlua scripts for dreamluau syntax. ## Why It's Good For The Game Code that runs on production servers should not depend on memory hacks that are liable to break any time Dream Daemon updates. ## Changelog 🆑 admin: Admin lua scripting uses a new library that (probably) will not break when BYOND updates. /🆑 ## TODO: - [x] Convert the lua editor ui to TS - [x] Include a guide for converting scripts from auxlua syntax to dreamluau syntax
This commit is contained in:
@@ -2,19 +2,19 @@ local state = require("state")
|
||||
|
||||
local Timer = {}
|
||||
|
||||
local SSlua = dm.global_vars:get_var("SSlua")
|
||||
local SSlua = dm.global_vars.SSlua
|
||||
__Timer_timers = __Timer_timers or {}
|
||||
__Timer_callbacks = __Timer_callbacks or {}
|
||||
|
||||
function __add_internal_timer(func, time, loop)
|
||||
local timer = {
|
||||
loop = loop,
|
||||
executeTime = time + dm.world:get_var("time")
|
||||
executeTime = time + dm.world.time,
|
||||
}
|
||||
__Timer_callbacks[tostring(func)] = function()
|
||||
timer.executing = false
|
||||
if loop and timer.terminate ~= true then
|
||||
timer.executeTime = dm.world:get_var("time") + time
|
||||
timer.executeTime = dm.world.time + time
|
||||
else
|
||||
__stop_internal_timer(tostring(func))
|
||||
end
|
||||
@@ -37,22 +37,21 @@ function __stop_internal_timer(func)
|
||||
end
|
||||
|
||||
__Timer_timer_processing = __Timer_timer_processing or false
|
||||
state.state:set_var("timer_enabled", 1)
|
||||
state.state.timer_enabled = 1
|
||||
__Timer_timer_process = function(seconds_per_tick)
|
||||
if __Timer_timer_processing then
|
||||
return 0
|
||||
end
|
||||
__Timer_timer_processing = true
|
||||
local time = dm.world:get_var("time")
|
||||
for func, timeData in __Timer_timers do
|
||||
if timeData.executing == true then
|
||||
continue
|
||||
end
|
||||
if over_exec_usage(0.85) then
|
||||
if _exec.time / (dm.world.tick_lag * 100) > 0.85 then
|
||||
sleep()
|
||||
end
|
||||
if time >= timeData.executeTime then
|
||||
state.state:get_var("functions_to_execute"):add(func)
|
||||
if dm.world.time >= timeData.executeTime then
|
||||
list.add(state.state.functions_to_execute, func)
|
||||
timeData.executing = true
|
||||
end
|
||||
end
|
||||
@@ -61,9 +60,8 @@ __Timer_timer_process = function(seconds_per_tick)
|
||||
end
|
||||
|
||||
function Timer.wait(time)
|
||||
local next_yield_index = __next_yield_index
|
||||
__add_internal_timer(function()
|
||||
SSlua:call_proc("queue_resume", state.state, next_yield_index)
|
||||
SSlua:queue_resume(state.state, _exec.next_yield_index)
|
||||
end, time * 10, false)
|
||||
coroutine.yield()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user