mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
Add support for pairs() in core.chatcommands and also fix a typo
This commit is contained in:
parent
d4cf76678a
commit
f207d60886
2 changed files with 12088 additions and 6 deletions
|
@ -43,18 +43,27 @@ end
|
|||
-- Chat command handler
|
||||
--
|
||||
|
||||
-- Unsure how to handle pairs()
|
||||
core.chatcommands = setmetatable({}, {
|
||||
__index=function (_, k)
|
||||
core.log("warn", "core.chatcommands is deprecated, use core.registered_chatcommands instead")
|
||||
--- Deprecated core.chatcommands
|
||||
core.chatcommands = setmetatable(table.copy(core.registered_chatcommands), {
|
||||
__index = function (_, k)
|
||||
core.log("warning", "core.chatcommands is deprecated, use core.registered_chatcommands instead.")
|
||||
return core.registered_chatcommands[k]
|
||||
end,
|
||||
__newindex=function (_, k, v)
|
||||
core.log("warn", "core.chatcommands is deprecated, use core.registered_chatcommands instead")
|
||||
__newindex = function (_, k, v)
|
||||
core.log("warning", "core.chatcommands is deprecated, use core.registered_chatcommands instead.")
|
||||
rawset(core.chatcommands, k, v)
|
||||
core.registered_chatcommands[k] = v
|
||||
end,
|
||||
})
|
||||
|
||||
--- For support pairs() with core.chatcommands
|
||||
setmetatable(core.registered_chatcommands, {
|
||||
__newindex = function (t, k, v)
|
||||
rawset(t, k, v)
|
||||
rawset(core.chatcommands, k, v)
|
||||
end
|
||||
})
|
||||
|
||||
local msg_time_threshold =
|
||||
tonumber(core.settings:get("chatcommand_msg_time_threshold")) or 0.1
|
||||
core.register_on_chat_message(function(name, message)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue