cleanup internal functions

This commit is contained in:
MihailRis 2026-09-01 23:32:44 +03:00
parent 39a3c1201f
commit 6c568e6706
8 changed files with 47 additions and 60 deletions

View file

@ -1,3 +1,5 @@
local internals = __vc_internals
local updating_blocks = {}
local present_queues = {}
local REGISTER_BIT = 0x1
@ -5,7 +7,7 @@ local UPDATING_BIT = 0x2
local PRESENT_BIT = 0x4
local REMOVED_BIT = 0x8
block.__perform_ticks = function(delta)
function internals.tick_updating_blocks(delta)
for id, entry in pairs(updating_blocks) do
entry.timer = entry.timer + delta
local steps = math.floor(entry.timer / entry.delta * #entry / 3)
@ -63,7 +65,7 @@ end
local block_pull_register_events = block.__pull_register_events
block.__pull_register_events = nil
block.__process_register_events = function()
function internals.process_block_register_events()
local register_events = block_pull_register_events()
if not register_events then
return

View file

@ -36,7 +36,7 @@ local function configure_SSAO()
update_ssao_quality(app.get_setting("graphics.ssao"))
end
local function __vc_on_hud_open()
function internals.on_hud_open()
local _hud_is_content_access = hud._is_content_access
local _hud_set_content_access = hud._set_content_access
local _hud_set_debug_cheats = hud._set_debug_cheats
@ -131,7 +131,8 @@ local function ScheduleGroup()
end
local RULES_FILE = "world:rules.toml"
local function __vc_on_world_open()
function internals.on_world_open()
time.schedules.world = ScheduleGroup()
if not file.exists(RULES_FILE) then
@ -143,15 +144,15 @@ local function __vc_on_world_open()
end
end
local function __vc_on_world_tick(tps)
function internals.on_world_tick(tps)
time.schedules.world:tick(1.0 / tps)
end
local function __vc_process_before_quit()
block.__process_register_events()
function internals.process_before_quit()
internals.process_block_register_events()
end
local function __vc_on_world_save()
function internals.on_world_save()
local rule_values = {}
for name, rule in pairs(__rules.rules) do
rule_values[name] = rule.value
@ -178,8 +179,6 @@ local __post_runnables = {}
local fn_audio_reset_fetch_buffer = audio.__reset_fetch_buffer
audio.__reset_fetch_buffer = nil
local __vc_update_coroutines = _G.__vc_update_coroutines
local function __process_post_runnables()
if #__post_runnables > 0 then
for _, func in ipairs(__post_runnables) do
@ -191,26 +190,30 @@ local function __process_post_runnables()
__post_runnables = {}
end
__vc_update_coroutines()
internals.update_coroutines()
fn_audio_reset_fetch_buffer()
debug.pull_events()
network.__process_events()
if not hud or not hud.is_paused() then
block.__process_register_events()
block.__perform_ticks(time.delta())
internals.process_block_register_events()
internals.tick_updating_blocks(time.delta())
end
end
local __vc__is_post_runnable = false
local is_post_runnable = false
function __vc__process_post_runnables()
__vc__is_post_runnable = true
function internals.process_post_runnables()
is_post_runnable = true
local success, err = pcall(__process_post_runnables)
if not success then
debug.error("an error ocurred while processing post-runnables: ".. err)
end
__vc__is_post_runnable = false
is_post_runnable = false
end
function internals.is_post_runnable_context()
return is_post_runnable
end
function time.post_runnable(runnable)
@ -221,14 +224,4 @@ function internals.on_render()
internals.on_animation_frame()
end
return {
__vc_on_hud_open = __vc_on_hud_open,
__vc_on_world_open = __vc_on_world_open,
__vc_on_world_tick = __vc_on_world_tick,
__vc_process_before_quit = __vc_process_before_quit,
__vc_on_world_save = __vc_on_world_save,
__vc__process_post_runnables = __vc__process_post_runnables,
__vc_is_post_runnable_context = function()
return __vc__is_post_runnable
end
}
return {}

View file

@ -1,4 +1,5 @@
local __app = __vc_app
local internals = __vc_internals
local enable_experimental = __app.get_setting("debug.enable-experimental")
------------------------------------------------
@ -45,7 +46,7 @@ local function complete_app_lib(app)
app.tick = __app_tick
local function call_in_app_script_co(func, ...)
if __vc_is_post_runnable_context() then
if internals.post_runnable_context() then
func(...)
return
end
@ -208,7 +209,7 @@ function start_coroutine(chunk, name)
__vc_named_coroutines[name] = co
end
function __vc_update_coroutines()
function internals.update_coroutines()
local dead = {}
for name, co in pairs(__vc_named_coroutines) do
local success, err = coroutine.resume(co)
@ -368,6 +369,7 @@ core.get_core_token = audio.input.__get_core_token
require "core:internal/console"
require "core:internal/deprecated"
require "core:internal/internal_events"
------------------------------------------
@ -397,5 +399,4 @@ __vc_app = nil
__vc_internals = nil
__vc_lock_internal_modules()
__vc_lock_internal_modules = nil
__vc_update_coroutines = nil
__VC_SCRIPT_NAME = ""