mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-11 05:51:51 +00:00
standard commands update
This commit is contained in:
parent
8d6f52c1fa
commit
bb4f573d0f
1 changed files with 18 additions and 4 deletions
|
|
@ -1,6 +1,18 @@
|
||||||
local SEPARATOR = "________________"
|
local SEPARATOR = "________________"
|
||||||
SEPARATOR = SEPARATOR..SEPARATOR..SEPARATOR
|
SEPARATOR = SEPARATOR..SEPARATOR..SEPARATOR
|
||||||
|
|
||||||
|
function build_scheme(command)
|
||||||
|
local str = command.name.." "
|
||||||
|
for i,arg in ipairs(command.args) do
|
||||||
|
if arg.optional then
|
||||||
|
str = str.."["..arg.name.."] "
|
||||||
|
else
|
||||||
|
str = str.."<"..arg.name.."> "
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return str
|
||||||
|
end
|
||||||
|
|
||||||
console.add_command(
|
console.add_command(
|
||||||
"help name:str=''",
|
"help name:str=''",
|
||||||
"Show help infomation for the specified command",
|
"Show help infomation for the specified command",
|
||||||
|
|
@ -9,9 +21,11 @@ console.add_command(
|
||||||
if #name == 0 then
|
if #name == 0 then
|
||||||
local commands = console.get_commands_list()
|
local commands = console.get_commands_list()
|
||||||
table.sort(commands)
|
table.sort(commands)
|
||||||
return "available commands: "..
|
local str = "Available commands:"
|
||||||
table.tostring(commands)..
|
for i,k in ipairs(commands) do
|
||||||
"\nuse 'help [command]'"
|
str = str.."\n "..build_scheme(console.get_command_info(k))
|
||||||
|
end
|
||||||
|
return str.."\nuse 'help <command>'"
|
||||||
end
|
end
|
||||||
local command = console.get_command_info(name)
|
local command = console.get_command_info(name)
|
||||||
if command == nil then
|
if command == nil then
|
||||||
|
|
@ -37,7 +51,7 @@ console.add_command(
|
||||||
)
|
)
|
||||||
|
|
||||||
console.add_command(
|
console.add_command(
|
||||||
"tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z",
|
"obj.tp obj:sel=$obj.id x:num~pos.x y:num~pos.y z:num~pos.z",
|
||||||
"Teleport object",
|
"Teleport object",
|
||||||
function (args, kwargs)
|
function (args, kwargs)
|
||||||
player.set_pos(unpack(args))
|
player.set_pos(unpack(args))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue