Chat command overwrite
Closed this issue · 1 comments
apachano commented
When registering chat commands only the last command registered by a given name works. For example if I put this code in my init.lua
ChatCmdBuilder.new("money",
function(cmd)
cmd:sub("check :playername", function(name, playername)
local player = minetest.get_player_by_name(playername)
minetest.chat_send_player(minetest.get_player_by_name(name),"ran check command")
minetest.chat_send_player(name, money.get(player))
end)
end, {
description = "get player money value",
privs = {
interact = true
}
}
)
ChatCmdBuilder.new("money",
function(cmd)
cmd:sub("balance", function(name)
local player = minetest.get_player_by_name(name)
minetest.chat_send_player(name, money.get(player))
end)
end, {
description = "get player money value",
privs = {
interact = true
}
}
)
only /money balance
gets registered and if I run /money check <playername>
then the balance command still runs. I can actually put any value in place of "balance" and still have balance run.
I register multiple commands to set multiple permissions within /money for example /money send
is usable by everybody but /money give
(creates money from thin air) requires the money_create permission.
rubenwardy commented
This is something I'd like to support. Here's an issue for a proposed new API: #6