forked from VoxeLibre/VoxeLibre
add 2 more patterns types (WIP)
This commit is contained in:
parent
a22188ccf4
commit
0d3147b13d
|
@ -68,7 +68,5 @@ If not specified, a value will be by default with the word pattern.
|
|||
* alphanumeric
|
||||
* username: value must be a valid username
|
||||
* json: value must be a json string (will be parsed automaticaly)
|
||||
|
||||
TODO:
|
||||
* color value must be a color string or a valid named color
|
||||
* nodename value must be a valid node name
|
||||
|
|
|
@ -22,7 +22,9 @@ mcl_commands.types = {
|
|||
alphascore = "([A-Za-z_]+)",
|
||||
alphanumeric = "([A-Za-z0-9]+)",
|
||||
username = "([A-Za-z0-9-_]+)",
|
||||
json = "(.+)",
|
||||
json = "(.+)", --FIXME
|
||||
color = "([^ ]+)", --FIXME
|
||||
nodename = "([A-Za-z_]+)",
|
||||
}
|
||||
|
||||
function mcl_commands.register_command(name, def)
|
||||
|
@ -201,6 +203,16 @@ function mcl_commands.build(name, chat_def)
|
|||
elseif param == "json" then
|
||||
table.insert(params, parse_json(res[pointer]))
|
||||
pointer = pointer + 1
|
||||
elseif param == "color" then
|
||||
table.insert(params, mcl_util.get_color(res[pointer]))
|
||||
pointer = pointer + 1
|
||||
elseif param == "nodename" then
|
||||
if minetest.registered_nodes[res[pointer]] then
|
||||
table.insert(params, res[pointer])
|
||||
pointer = pointer + 1
|
||||
else
|
||||
return false, S("Param "..pointer.." must be a valid nodename!")
|
||||
end
|
||||
else
|
||||
table.insert(params, res[pointer])
|
||||
pointer = pointer + 1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name = mcl_commands
|
||||
author = AFCMS
|
||||
description = MCL2 commands API
|
||||
depends = mcl_colors
|
||||
depends = mcl_colors, mcl_util
|
||||
optional_depends =
|
||||
|
||||
|
|
|
@ -2,14 +2,10 @@ local S = minetest.get_translator("mcl_commands")
|
|||
|
||||
mcl_commands.register_command("setblock", {
|
||||
func = function(cmd)
|
||||
cmd:sub(":pos:pos :node:text", { --TODO:replace by upcomming nodename type
|
||||
func = function(name)
|
||||
local itemstack = ItemStack(nodestring)
|
||||
if itemstack:is_empty() or not minetest.registered_nodes[itemstack:get_name()] then
|
||||
return false, S("Invalid node") --workaround
|
||||
end
|
||||
minetest.set_node(p, {name=nodestring})
|
||||
return true, S("@1 spawned.", nodestring)
|
||||
cmd:sub(":pos:pos :node:nodename", {
|
||||
func = function(name, pos, node)
|
||||
minetest.set_node(pos, {name=node})
|
||||
return true, S("@1 spawned.", node)
|
||||
--return false, S("Invalid parameters (see /help setblock)")
|
||||
end,
|
||||
privs = {},
|
||||
|
|
Loading…
Reference in New Issue