mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
core: finish initial register_command
This commit is contained in:
parent
19c8d0e7b9
commit
fa9b511e33
1 changed files with 10 additions and 3 deletions
|
@ -5,6 +5,9 @@
|
||||||
-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██
|
-- ██ ██ ███████ ██████ ██ ███████ ██ ███████ ██ ██
|
||||||
|
|
||||||
-- WorldEditAdditions chat command registration
|
-- WorldEditAdditions chat command registration
|
||||||
|
local we_c = worldeditadditions_core
|
||||||
|
|
||||||
|
local run_command = dofile(we_c.modpath.."/core/run_command.lua")
|
||||||
|
|
||||||
local function log_error(cmdname, error_message)
|
local function log_error(cmdname, error_message)
|
||||||
minetest.log("error", "register_command("..cmdname..") error: "..error_message)
|
minetest.log("error", "register_command("..cmdname..") error: "..error_message)
|
||||||
|
@ -30,6 +33,10 @@ local function register_command(cmdname, options)
|
||||||
log_error(cmdname, "The func option is not a function.")
|
log_error(cmdname, "The func option is not a function.")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
if we_c.registered_commands[cmdname] and options.override ~= true then
|
||||||
|
log_error(cmdname, "A WorldEditAdditions command with that name is registered, but the option override is not set to true.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -37,7 +44,7 @@ local function register_command(cmdname, options)
|
||||||
---
|
---
|
||||||
if not options.privs then options.privs = {} end
|
if not options.privs then options.privs = {} end
|
||||||
if not options.require_pos then options.require_pos = 0 end
|
if not options.require_pos then options.require_pos = 0 end
|
||||||
if not options.nodes_needed then options.nodes_needed = function() return 0 end
|
if not options.nodes_needed then options.nodes_needed = function() return 0 end end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- 3: Registration
|
-- 3: Registration
|
||||||
|
@ -47,8 +54,8 @@ local function register_command(cmdname, options)
|
||||||
description = options.description,
|
description = options.description,
|
||||||
privs = options.privs,
|
privs = options.privs,
|
||||||
func = function(player_name, paramtext)
|
func = function(player_name, paramtext)
|
||||||
-- TODO: Fill this in
|
run_command(cmdname, player_name, paramtext)
|
||||||
end
|
end
|
||||||
|
|
||||||
})
|
})
|
||||||
|
we_c.registered_commands[cmdname] = options
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue