mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Add luacheck to check builtin (#7895)
This commit is contained in:
parent
8da35c22d1
commit
8e757859d6
24 changed files with 202 additions and 140 deletions
|
@ -250,7 +250,6 @@ end
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
function compare_worlds(world1,world2)
|
||||
|
||||
if world1.path ~= world2.path then
|
||||
return false
|
||||
end
|
||||
|
|
|
@ -31,7 +31,6 @@ local mod_cmds = {}
|
|||
local function load_mod_command_tree()
|
||||
mod_cmds = {}
|
||||
|
||||
local check_player_privs = core.check_player_privs
|
||||
for name, def in pairs(core.registered_chatcommands) do
|
||||
mod_cmds[def.mod_origin] = mod_cmds[def.mod_origin] or {}
|
||||
local cmds = mod_cmds[def.mod_origin]
|
||||
|
@ -86,8 +85,8 @@ end
|
|||
|
||||
local function build_privs_formspec(name)
|
||||
local privs = {}
|
||||
for name, def in pairs(core.registered_privileges) do
|
||||
privs[#privs + 1] = { name, def }
|
||||
for priv_name, def in pairs(core.registered_privileges) do
|
||||
privs[#privs + 1] = { priv_name, def }
|
||||
end
|
||||
table.sort(privs, function(a, b) return a[1] < b[1] end)
|
||||
|
||||
|
@ -137,7 +136,7 @@ help_command.func = function(name, param)
|
|||
if param == "" or param == "all" then
|
||||
core.show_formspec(name, "__builtin:help_cmds",
|
||||
build_chatcommands_formspec(name))
|
||||
return
|
||||
return
|
||||
end
|
||||
|
||||
return old_help_func(name, param)
|
||||
|
|
|
@ -128,6 +128,7 @@ function dump(o, indent, nested, level)
|
|||
if t ~= "table" then
|
||||
return basic_dump(o)
|
||||
end
|
||||
|
||||
-- Contains table -> true/nil of currently nested tables
|
||||
nested = nested or {}
|
||||
if nested[o] then
|
||||
|
@ -136,10 +137,11 @@ function dump(o, indent, nested, level)
|
|||
nested[o] = true
|
||||
indent = indent or "\t"
|
||||
level = level or 1
|
||||
local t = {}
|
||||
|
||||
local ret = {}
|
||||
local dumped_indexes = {}
|
||||
for i, v in ipairs(o) do
|
||||
t[#t + 1] = dump(v, indent, nested, level + 1)
|
||||
ret[#ret + 1] = dump(v, indent, nested, level + 1)
|
||||
dumped_indexes[i] = true
|
||||
end
|
||||
for k, v in pairs(o) do
|
||||
|
@ -148,7 +150,7 @@ function dump(o, indent, nested, level)
|
|||
k = "["..dump(k, indent, nested, level + 1).."]"
|
||||
end
|
||||
v = dump(v, indent, nested, level + 1)
|
||||
t[#t + 1] = k.." = "..v
|
||||
ret[#ret + 1] = k.." = "..v
|
||||
end
|
||||
end
|
||||
nested[o] = nil
|
||||
|
@ -157,10 +159,10 @@ function dump(o, indent, nested, level)
|
|||
local end_indent_str = "\n"..string.rep(indent, level - 1)
|
||||
return string.format("{%s%s%s}",
|
||||
indent_str,
|
||||
table.concat(t, ","..indent_str),
|
||||
table.concat(ret, ","..indent_str),
|
||||
end_indent_str)
|
||||
end
|
||||
return "{"..table.concat(t, ", ").."}"
|
||||
return "{"..table.concat(ret, ", ").."}"
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -407,9 +409,8 @@ if INIT == "game" then
|
|||
end
|
||||
|
||||
local old_itemstack = ItemStack(itemstack)
|
||||
local new_itemstack, removed = core.item_place_node(
|
||||
itemstack, placer, pointed_thing, param2, prevent_after_place
|
||||
)
|
||||
local new_itemstack = core.item_place_node(itemstack, placer,
|
||||
pointed_thing, param2, prevent_after_place)
|
||||
return infinitestacks and old_itemstack or new_itemstack
|
||||
end
|
||||
|
||||
|
|
|
@ -218,4 +218,3 @@ test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"}
|
|||
test_out = core.deserialize(core.serialize(test_in))
|
||||
assert(test_in.escape_chars == test_out.escape_chars)
|
||||
assert(test_in.non_european == test_out.non_european)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue