mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-27 10:02:12 +00:00
* Fixes a lua state null return related to the print wrapper, improves the lua editor ui formatting, and implements a stopgap lua lag fix (#68816) This PR fixes this issue by making sure every proc called in the stack of /proc/wrap_lua_print which could sleep is called using INVOKE_ASYNC, and to prevent such problems in the future, marks all the wrappers as SHOULD_NOT_SLEEP(TRUE). I also figured out how to fix the dumb overflowing problem of the lua editor ui. Due to lag concerns regarding lua states with a large number of global variables (including fields within global tables), I have made it so the global table and state log are hidden by default - they can be shown using a toggle button in the editor ui. * Fixes a lua state null return related to the print wrapper, improves the lua editor ui formatting, and implements a stopgap lua lag fix Co-authored-by: Y0SH1M4S73R <legoboyo@earthlink.net>
48 lines
1.5 KiB
Plaintext
48 lines
1.5 KiB
Plaintext
/proc/wrap_lua_set_var(datum/thing_to_set, var_name, value)
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
thing_to_set.vv_edit_var(var_name, value)
|
|
|
|
/proc/wrap_lua_datum_proc_call(datum/thing_to_call, proc_name, list/arguments)
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
if(!usr)
|
|
usr = GLOB.lua_usr
|
|
var/ret
|
|
if(usr)
|
|
ret = WrapAdminProcCall(thing_to_call, proc_name, arguments)
|
|
else
|
|
ret = HandleUserlessProcCall("lua", thing_to_call, proc_name, arguments)
|
|
if(isdatum(ret))
|
|
SSlua.gc_guard = ret
|
|
var/datum/ret_datum = ret
|
|
ret_datum.RegisterSignal(ret_datum, COMSIG_PARENT_QDELETING, /datum.proc/lua_reference_cleanup, override = TRUE)
|
|
return ret
|
|
|
|
/proc/wrap_lua_global_proc_call(proc_name, list/arguments)
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
if(!usr)
|
|
usr = GLOB.lua_usr
|
|
var/ret
|
|
if(usr)
|
|
ret = WrapAdminProcCall(GLOBAL_PROC, proc_name, arguments)
|
|
else
|
|
ret = HandleUserlessProcCall("lua", GLOBAL_PROC, proc_name, arguments)
|
|
if(isdatum(ret))
|
|
SSlua.gc_guard = ret
|
|
var/datum/ret_datum = ret
|
|
ret_datum.RegisterSignal(ret_datum, COMSIG_PARENT_QDELETING, /datum.proc/lua_reference_cleanup, override = TRUE)
|
|
return ret
|
|
|
|
/proc/wrap_lua_print(state_id, list/arguments)
|
|
SHOULD_NOT_SLEEP(TRUE)
|
|
var/datum/lua_state/target_state
|
|
for(var/datum/lua_state/state as anything in SSlua.states)
|
|
if(state.internal_id == state_id)
|
|
target_state = state
|
|
break
|
|
if(!target_state)
|
|
return
|
|
var/print_message = jointext(arguments, "\t")
|
|
var/result = list("status" = "print", "param" = print_message)
|
|
INVOKE_ASYNC(target_state, /datum/lua_state.proc/log_result, result, TRUE)
|
|
log_lua("[target_state]: [print_message]")
|