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
|
* alphanumeric
|
||||||
* username: value must be a valid username
|
* username: value must be a valid username
|
||||||
* json: value must be a json string (will be parsed automaticaly)
|
* json: value must be a json string (will be parsed automaticaly)
|
||||||
|
|
||||||
TODO:
|
|
||||||
* color value must be a color string or a valid named color
|
* color value must be a color string or a valid named color
|
||||||
* nodename value must be a valid node name
|
* nodename value must be a valid node name
|
||||||
|
|
|
@ -22,7 +22,9 @@ mcl_commands.types = {
|
||||||
alphascore = "([A-Za-z_]+)",
|
alphascore = "([A-Za-z_]+)",
|
||||||
alphanumeric = "([A-Za-z0-9]+)",
|
alphanumeric = "([A-Za-z0-9]+)",
|
||||||
username = "([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)
|
function mcl_commands.register_command(name, def)
|
||||||
|
@ -201,6 +203,16 @@ function mcl_commands.build(name, chat_def)
|
||||||
elseif param == "json" then
|
elseif param == "json" then
|
||||||
table.insert(params, parse_json(res[pointer]))
|
table.insert(params, parse_json(res[pointer]))
|
||||||
pointer = pointer + 1
|
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
|
else
|
||||||
table.insert(params, res[pointer])
|
table.insert(params, res[pointer])
|
||||||
pointer = pointer + 1
|
pointer = pointer + 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name = mcl_commands
|
name = mcl_commands
|
||||||
author = AFCMS
|
author = AFCMS
|
||||||
description = MCL2 commands API
|
description = MCL2 commands API
|
||||||
depends = mcl_colors
|
depends = mcl_colors, mcl_util
|
||||||
optional_depends =
|
optional_depends =
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,10 @@ local S = minetest.get_translator("mcl_commands")
|
||||||
|
|
||||||
mcl_commands.register_command("setblock", {
|
mcl_commands.register_command("setblock", {
|
||||||
func = function(cmd)
|
func = function(cmd)
|
||||||
cmd:sub(":pos:pos :node:text", { --TODO:replace by upcomming nodename type
|
cmd:sub(":pos:pos :node:nodename", {
|
||||||
func = function(name)
|
func = function(name, pos, node)
|
||||||
local itemstack = ItemStack(nodestring)
|
minetest.set_node(pos, {name=node})
|
||||||
if itemstack:is_empty() or not minetest.registered_nodes[itemstack:get_name()] then
|
return true, S("@1 spawned.", node)
|
||||||
return false, S("Invalid node") --workaround
|
|
||||||
end
|
|
||||||
minetest.set_node(p, {name=nodestring})
|
|
||||||
return true, S("@1 spawned.", nodestring)
|
|
||||||
--return false, S("Invalid parameters (see /help setblock)")
|
--return false, S("Invalid parameters (see /help setblock)")
|
||||||
end,
|
end,
|
||||||
privs = {},
|
privs = {},
|
||||||
|
|
Loading…
Reference in New Issue