cleanup and fixes

This commit is contained in:
AFCMS 2021-03-09 12:47:57 +01:00
parent 5f00d47ec2
commit 31e256e1e2
2 changed files with 22 additions and 22 deletions

View File

@ -12,21 +12,21 @@ local get_modpath = minetest.get_modpath
mcl_commands = {} mcl_commands = {}
mcl_commands.types = { -- mcl_commands.types = {
pos = "%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?", -- pos = "%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?",
text = "(.+)", -- text = "(.+)",
number = "(%-?[%d.]+)", -- number = "(%-?[%d.]+)",
int = "(%-?[%d]+)", -- int = "(%-?[%d]+)",
word = "([^ ]+)", -- word = "([^ ]+)",
alpha = "([A-Za-z]+)", -- alpha = "([A-Za-z]+)",
modname = "([a-z0-9_]+)", -- modname = "([a-z0-9_]+)",
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 = "(.+)", --FIXME -- json = "(.+)", --FIXME
color = "([^ ]+)", --FIXME -- color = "([^ ]+)", --FIXME
nodename = "([A-Za-z_]+)", -- nodename = "([A-Za-z_]+)",
} -- }
mcl_commands.types = { mcl_commands.types = {
pos = {"%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?", pos = {"%(? *(%-?[%d.]+) *, *(%-?[%d.]+) *, *(%-?[%d.]+) *%)?",
@ -109,10 +109,11 @@ mcl_commands.types = {
username = {"([A-Za-z0-9-_]+)}", username = {"([A-Za-z0-9-_]+)}",
function(res, pointer) function(res, pointer)
--if minetest.player_exists(res[pointer]) then --if minetest.player_exists(res[pointer]) then
return nil, res[pointer], pointer+1 if res[pointer] then
--else return nil, res[pointer], pointer+1
--return S("Player doesn't exist.") else
--end return S("Player doesn't exist.")
end
end}, end},
json = {"(.+)", --FIXME json = {"(.+)", --FIXME
function(res, pointer) function(res, pointer)
@ -153,7 +154,7 @@ function mcl_commands.register_command(name, def)
return cmd return cmd
end end
function mcl_commands.overide_command(name, def) function mcl_commands.override_command(name, def)
def = def or {} def = def or {}
local cmd = mcl_commands.build(name, def) local cmd = mcl_commands.build(name, def)
if minetest.registered_chatcommands[name] then if minetest.registered_chatcommands[name] then

View File

@ -41,7 +41,7 @@ local function handle_kill_command(suspect, victim)
return true return true
end end
mcl_commands.overide_command("kill", { mcl_commands.override_command("kill", {
func = function(cmd) func = function(cmd)
cmd:sub("", { cmd:sub("", {
func = function(name) func = function(name)
@ -52,7 +52,6 @@ mcl_commands.overide_command("kill", {
func = function(name, target) func = function(name, target)
return handle_kill_command(name, target) return handle_kill_command(name, target)
end, end,
privs = {settime = true}
}) })
end, end,
description = "Kill player or yourself.", description = "Kill player or yourself.",