Minetest-WorldEditAdditions/worldeditadditions_core/core/fetch_command_def.lua
Starbeamrainbowlabs b816133716
core: implement fetch_command_def
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.
2022-05-19 02:31:01 +01:00

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