mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-08-21 05:54:06 +02:00
This rovides an abstraction to fetch a worldedit command's definition, regardless of where it was registered. We would normally expect all commands to be registered in wea_c.registered_commands, but before we only do a one-off pass to import commands from worldedit should a new mod we aren't aware of register a command with worldedit and get loaded after us, we won't detect it - hencee the need for this function.
21 lines
647 B
Lua
21 lines
647 B
Lua
|
|
|
|
--- Fetches the definition of a WorldEditAdditions or WorldEdit command
|
|
-- Does not support fetching generic Minetest commands - check
|
|
-- minetest.chatcommands for this.
|
|
-- @param cmdname string The name of the command to fetch the definition for.
|
|
local function fetch_command_def(cmdname)
|
|
local wea_c = worldeditadditions_core
|
|
|
|
if wea_c.registered_commands[cmdname] then
|
|
return wea_c.registered_commands[cmdname]
|
|
end
|
|
if minetest.global_exists("worldedit") and worldedit.registered_commands and worldedit.registered_commands[cmdname] then
|
|
return worldedit.registered_commands[cmdname]
|
|
end
|
|
|
|
return nil
|
|
end
|
|
|
|
return fetch_command_def
|