Skip to content

Commit 280c8a1

Browse files
committed
Override /pulverize and /clearinv to require interact
1 parent 052ccb0 commit 280c8a1

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

mods/default/chat.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 then
20+
if match_old(def.privs) then
21+
core.override_chatcommand(cmd, {
22+
privs = {interact=true},
23+
})
24+
else
25+
minetest.log("info", "Privileges of command /" .. cmd .. " look modified, not overriding them.")
26+
end
27+
end
28+
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)