Merge branch 'dev' into pathfinding

This commit is contained in:
MihailRis
2025-08-19 19:47:10 +03:00
57 changed files with 818 additions and 207 deletions
+1 -2
View File
@@ -62,5 +62,4 @@ end
cache_names(block)
cache_names(item)
local scripts_registry = require "core:internal/scripts_registry"
scripts_registry.build_registry()
__vc_scripts_registry.build_registry()
+11 -50
View File
@@ -1,3 +1,5 @@
local enable_experimental = core.get_setting("debug.enable-experimental")
------------------------------------------------
------ Extended kit of standard functions ------
------------------------------------------------
@@ -36,7 +38,6 @@ local function complete_app_lib(app)
app.set_setting = core.set_setting
app.tick = function()
coroutine.yield()
network.__process_events()
end
app.get_version = core.get_version
app.get_setting_info = core.get_setting_info
@@ -169,61 +170,16 @@ function inventory.set_description(invid, slot, description)
inventory.set_data(invid, slot, "description", description)
end
------------------------------------------------
------------------- Events ---------------------
------------------------------------------------
events = {
handlers = {}
}
function events.on(event, func)
if events.handlers[event] == nil then
events.handlers[event] = {}
end
table.insert(events.handlers[event], func)
if enable_experimental then
require "core:internal/maths_inline"
end
function events.reset(event, func)
if func == nil then
events.handlers[event] = nil
else
events.handlers[event] = {func}
end
end
function events.remove_by_prefix(prefix)
for name, handlers in pairs(events.handlers) do
local actualname = name
if type(name) == 'table' then
actualname = name[1]
end
if actualname:sub(1, #prefix+1) == prefix..':' then
events.handlers[actualname] = nil
end
end
end
events = require "core:internal/events"
function pack.unload(prefix)
events.remove_by_prefix(prefix)
end
function events.emit(event, ...)
local result = nil
local handlers = events.handlers[event]
if handlers == nil then
return nil
end
for _, func in ipairs(handlers) do
local status, newres = xpcall(func, __vc__error, ...)
if not status then
debug.error("error in event ("..event..") handler: "..newres)
else
result = result or newres
end
end
return result
end
gui_util = require "core:internal/gui_util"
Document = gui_util.Document
@@ -238,6 +194,7 @@ end
_GUI_ROOT = Document.new("core:root")
_MENU = _GUI_ROOT.menu
menu = _MENU
gui.root = _GUI_ROOT
--- Console library extension ---
console.cheats = {}
@@ -319,11 +276,12 @@ entities.get_all = function(uids)
end
local bytearray = require "core:internal/bytearray"
Bytearray = bytearray.FFIBytearray
Bytearray_as_string = bytearray.FFIBytearray_as_string
Bytearray_construct = function(...) return Bytearray(...) end
__vc_scripts_registry = require "core:internal/scripts_registry"
file.open = require "core:internal/stream_providers/file"
file.open_named_pipe = require "core:internal/stream_providers/named_pipe"
@@ -342,6 +300,7 @@ else
end
ffi = nil
__vc_lock_internal_modules()
math.randomseed(time.uptime() * 1536227939)
@@ -612,6 +571,8 @@ function __process_post_runnables()
for _, name in ipairs(dead) do
__vc_named_coroutines[name] = nil
end
network.__process_events()
end
function time.post_runnable(runnable)
+11
View File
@@ -550,6 +550,8 @@ function reload_module(name)
end
end
local internal_locked = false
-- Load script with caching
--
-- path - script path `contentpack:filename`.
@@ -559,6 +561,11 @@ end
function __load_script(path, nocache)
local packname, filename = parse_path(path)
if internal_locked and (packname == "res" or packname == "core")
and filename:starts_with("modules/internal") then
error("access to core:internal modules outside of [core]")
end
-- __cached_scripts used in condition because cached result may be nil
if not nocache and __cached_scripts[path] ~= nil then
return package.loaded[path]
@@ -579,6 +586,10 @@ function __load_script(path, nocache)
return result
end
function __vc_lock_internal_modules()
internal_locked = true
end
function require(path)
if not string.find(path, ':') then
local prefix, _ = parse_path(_debug_getinfo(2).source)