Skip to content

Commit 4e8d186

Browse files
committed
Override /pulverize and /clearinv to require no privs
1 parent 052ccb0 commit 4e8d186

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

mods/default/chat.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- mods/default/chat.lua
2+
3+
local function match_old(privs)
4+
local ok = false
5+
for k, v in pairs(privs) do
6+
if k == "give" and v then
7+
ok = true
8+
elseif v then
9+
return false
10+
end
11+
end
12+
return ok
13+
end
14+
15+
-- Change /pulverize and /clearinv to not require give, like it used to be
16+
-- before Luanti 5.15
17+
for _, cmd in ipairs({"pulverize", "clearinv"}) do
18+
local def = core.registered_chatcommands[cmd]
19+
if def and def.privs then
20+
if match_old(def.privs) then
21+
def.privs = {}
22+
else
23+
minetest.log("info", "Privileges of command /" .. cmd .. " look modified, not overriding them.")
24+
end
25+
end
26+
end

mods/default/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ dofile(default_path.."/item_entity.lua")
7575
dofile(default_path.."/craftitems.lua")
7676
dofile(default_path.."/crafting.lua")
7777
dofile(default_path.."/mapgen.lua")
78+
dofile(default_path.."/chat.lua")
7879
dofile(default_path.."/aliases.lua")
7980
dofile(default_path.."/legacy.lua")
8081

0 commit comments

Comments
 (0)