mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Merge 3ac8e4e974
into 499f2284bd
This commit is contained in:
commit
2fbcaf5bb3
50 changed files with 1545 additions and 94 deletions
|
@ -13,3 +13,6 @@ dofile(commonpath .. "information_formspecs.lua")
|
|||
dofile(clientpath .. "chatcommands.lua")
|
||||
dofile(clientpath .. "misc.lua")
|
||||
assert(loadfile(commonpath .. "item_s.lua"))({}) -- Just for push/read node functions
|
||||
|
||||
-- unset, as promised in initializeSecurityClient()
|
||||
debug.getinfo = nil
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local builtin_shared = ...
|
||||
local debug_getinfo = debug.getinfo
|
||||
|
||||
do
|
||||
local default = {mod = "??", name = "??"}
|
||||
|
@ -56,7 +57,7 @@ function builtin_shared.make_registration()
|
|||
core.callback_origins[func] = {
|
||||
-- may be nil or return nil
|
||||
mod = core.get_current_modname and core.get_current_modname() or "??",
|
||||
name = debug.getinfo(1, "n").name or "??"
|
||||
name = debug_getinfo(1, "n").name or "??"
|
||||
}
|
||||
end
|
||||
return t, registerfunc
|
||||
|
@ -69,7 +70,7 @@ function builtin_shared.make_registration_reverse()
|
|||
core.callback_origins[func] = {
|
||||
-- may be nil or return nil
|
||||
mod = core.get_current_modname and core.get_current_modname() or "??",
|
||||
name = debug.getinfo(1, "n").name or "??"
|
||||
name = debug_getinfo(1, "n").name or "??"
|
||||
}
|
||||
end
|
||||
return t, registerfunc
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local getinfo, rawget, rawset = debug.getinfo, rawget, rawset
|
||||
local debug_getinfo, rawget, rawset = debug.getinfo, rawget, rawset
|
||||
|
||||
function core.global_exists(name)
|
||||
if type(name) ~= "string" then
|
||||
|
@ -18,7 +18,7 @@ function meta:__newindex(name, value)
|
|||
if declared[name] then
|
||||
return
|
||||
end
|
||||
local info = getinfo(2, "Sl")
|
||||
local info = debug_getinfo(2, "Sl")
|
||||
if info ~= nil then
|
||||
local desc = ("%s:%d"):format(info.short_src, info.currentline)
|
||||
local warn_key = ("%s\0%d\0%s"):format(info.source, info.currentline, name)
|
||||
|
@ -36,7 +36,7 @@ function meta:__index(name)
|
|||
if declared[name] then
|
||||
return
|
||||
end
|
||||
local info = getinfo(2, "Sl")
|
||||
local info = debug_getinfo(2, "Sl")
|
||||
if info == nil then
|
||||
return
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
local builtin_shared = ...
|
||||
local S = core.get_translator("__builtin")
|
||||
local debug_getinfo = debug.getinfo
|
||||
|
||||
--
|
||||
-- Make raw registration functions inaccessible to anyone except this file
|
||||
|
@ -548,7 +549,7 @@ function core.registered_on_player_hpchange(player, hp_change, reason)
|
|||
local func = core.registered_on_player_hpchanges.modifiers[i]
|
||||
hp_change, last = func(player, hp_change, reason)
|
||||
if type(hp_change) ~= "number" then
|
||||
local debuginfo = debug.getinfo(func)
|
||||
local debuginfo = debug_getinfo(func)
|
||||
error("The register_on_hp_changes function has to return a number at " ..
|
||||
debuginfo.short_src .. " line " .. debuginfo.linedefined)
|
||||
end
|
||||
|
@ -570,7 +571,7 @@ function core.register_on_player_hpchange(func, modifier)
|
|||
end
|
||||
core.callback_origins[func] = {
|
||||
mod = core.get_current_modname() or "??",
|
||||
name = debug.getinfo(1, "n").name or "??"
|
||||
name = debug_getinfo(1, "n").name or "??"
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
@ -76,6 +76,10 @@ elseif INIT == "async_game" then
|
|||
dofile(asyncpath .. "game.lua")
|
||||
elseif INIT == "client" then
|
||||
dofile(scriptdir .. "client" .. DIR_DELIM .. "init.lua")
|
||||
elseif INIT == "sscsm" and core.get_current_modname() == "*client_builtin*" then
|
||||
dofile(scriptdir .. "sscsm_client" .. DIR_DELIM .. "init.lua")
|
||||
elseif INIT == "sscsm" and core.get_current_modname() == "*server_builtin*" then
|
||||
dofile(scriptdir .. "sscsm_server" .. DIR_DELIM .. "init.lua")
|
||||
elseif INIT == "emerge" then
|
||||
dofile(scriptdir .. "emerge" .. DIR_DELIM .. "init.lua")
|
||||
elseif INIT == "pause_menu" then
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
local format, ipairs, type = string.format, ipairs, type
|
||||
local core, get_current_modname = core, core.get_current_modname
|
||||
local profiler, sampler = ...
|
||||
local debug_getinfo = debug.getinfo
|
||||
|
||||
local instrument_builtin = core.settings:get_bool("instrument.builtin", false)
|
||||
|
||||
|
@ -67,7 +68,7 @@ local worldmods_path = regex_escape(core.get_worldpath())
|
|||
local user_path = regex_escape(core.get_user_path())
|
||||
local builtin_path = regex_escape(core.get_builtin_path())
|
||||
local function generate_source_location(def)
|
||||
local info = debug.getinfo(def.func)
|
||||
local info = debug_getinfo(def.func)
|
||||
local modpath = regex_escape(core.get_modpath(def.mod) or "")
|
||||
local source = info.source
|
||||
if modpath ~= "" then
|
||||
|
|
|
@ -1883,6 +1883,10 @@ mgvalleys_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500),
|
|||
# This support is experimental and API can change.
|
||||
enable_client_modding (Client modding) [client] bool false
|
||||
|
||||
# Where to enable server-sent client-side modding (SSCSM).
|
||||
# Warning: Experimental.
|
||||
enable_sscsm (Enable SSCSM) [client] enum nowhere nowhere,singleplayer,localhost,lan,everywhere
|
||||
|
||||
# Replaces the default main menu with a custom one.
|
||||
main_menu_script (Main menu script) [client] string
|
||||
|
||||
|
|
25
builtin/sscsm_client/init.lua
Normal file
25
builtin/sscsm_client/init.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
local scriptpath = core.get_builtin_path()
|
||||
local commonpath = scriptpath .. "common" .. DIR_DELIM
|
||||
local mypath = scriptpath .. "sscsm_client".. DIR_DELIM
|
||||
|
||||
-- Shared between builtin files, but
|
||||
-- not exposed to outer context
|
||||
local builtin_shared = {}
|
||||
|
||||
-- placeholders
|
||||
-- FIXME: send actual content defs to sscsm env
|
||||
function core.get_content_id(name)
|
||||
return tonumber(name)
|
||||
end
|
||||
function core.get_name_from_content_id(id)
|
||||
return tostring(id)
|
||||
end
|
||||
|
||||
assert(loadfile(commonpath .. "item_s.lua"))(builtin_shared)
|
||||
assert(loadfile(commonpath .. "register.lua"))(builtin_shared)
|
||||
assert(loadfile(mypath .. "register.lua"))(builtin_shared)
|
||||
|
||||
dofile(commonpath .. "after.lua")
|
||||
|
||||
-- unset, as promised in initializeSecuritySSCSM()
|
||||
debug.getinfo = nil
|
5
builtin/sscsm_client/register.lua
Normal file
5
builtin/sscsm_client/register.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
local builtin_shared = ...
|
||||
|
||||
local make_registration = builtin_shared.make_registration
|
||||
|
||||
core.registered_globalsteps, core.register_globalstep = make_registration()
|
0
builtin/sscsm_server/init.lua
Normal file
0
builtin/sscsm_server/init.lua
Normal file
Loading…
Add table
Add a link
Reference in a new issue