Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions mods/default/chat.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- mods/default/chat.lua

local function match_old(privs)
local ok = false
for k, v in pairs(privs) do
if k == "give" and v then
ok = true
elseif v then
return false
end
end
return ok
end

-- Change /pulverize and /clearinv to not require give, like it used to be
-- before Luanti 5.15
for _, cmd in ipairs({"pulverize", "clearinv"}) do
local def = core.registered_chatcommands[cmd]
if def then
if match_old(def.privs) then
Copy link
Member

@SmallJoker SmallJoker Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This depends on the mod load order. I think it would be more straight-forward to
EITHER:
Use a simple, general logic as possible:

if def.privs.give then
	def.privs.give = nil
	def.privs.interact = true
end

OR:
Execute this in a on_mods_loaded callback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a problem? If another mod wants to be sure to override it, it should depend on default

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷. It depends on how the mod manipulates the table, whether an additional priv is added (assuming interact would be there too), or it's overwritten entirely. The code also seemed to me more complicated than it should be.

Anyway. I don't think this really matters, thus 👍

core.override_chatcommand(cmd, {
privs = {interact=true},
})
else
minetest.log("info", "Privileges of command /" .. cmd .. " look modified, not overriding them.")
end
end
end
1 change: 1 addition & 0 deletions mods/default/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ dofile(default_path.."/item_entity.lua")
dofile(default_path.."/craftitems.lua")
dofile(default_path.."/crafting.lua")
dofile(default_path.."/mapgen.lua")
dofile(default_path.."/chat.lua")
dofile(default_path.."/aliases.lua")
dofile(default_path.."/legacy.lua")

Expand Down