2014-06-22 10:01:16 +02:00
computers.register_oscommand ( " help " , " get help about a function " , " help [COMMAND] " , function ( cmdline , pos , player )
2014-06-20 09:51:45 +02:00
local command = string.match ( cmdline , " help *(.+) " )
2014-06-22 10:01:16 +02:00
local message = " "
2014-06-20 09:51:45 +02:00
if command == nil then
2014-06-22 10:01:16 +02:00
for i = 1 , # computers.registered_command_names do
local name = computers.registered_command_names [ i ]
local short_desc = computers.registered_commands [ name ] . short_description
message = message .. name .. " " .. short_desc .. " \n "
end
message = message .. " \n type \" help COMMAND \" to get usage "
elseif command ~= nil and computers.registered_commands [ command ] ~= nil then
message = command .. " : \t " .. computers.registered_commands [ command ] . short_description .. " \n usage: \n " .. computers.registered_commands [ command ] . long_description
2014-06-20 09:51:45 +02:00
end
2014-06-22 10:01:16 +02:00
if message == " " then
2014-06-20 09:51:45 +02:00
message = " no help for this command "
end
2014-06-22 10:01:16 +02:00
2014-06-20 09:51:45 +02:00
return message , true
end )
2014-06-22 10:01:16 +02:00
computers.register_oscommand ( " time " , " get the time of day " , " time " , function ( cmdline , pos , player )
local message = " local time : " .. ( minetest.env : get_timeofday ( ) * 24 )
2014-06-20 09:51:45 +02:00
return message , true
2014-06-22 10:01:16 +02:00
end )
2014-06-20 09:51:45 +02:00
2014-06-22 10:01:16 +02:00
computers.register_oscommand ( " gps " , " localize a player " , " gps [-c PLAYER get coordinates] \n [-d PLAYER get distance between computer and player] \n [-r PLAYER get relative coordinates] " ,
function ( cmdline , pos , player )
local message = " gps: error: unable to connect to satellite (in devel program) "
2014-06-20 09:51:45 +02:00
return message , true
2014-06-22 10:01:16 +02:00
end )
2014-06-20 09:51:45 +02:00
2014-06-22 10:01:16 +02:00
computers.register_oscommand ( " mat " , " get the material name of a bloc next to the computer " , " mat [z+1] [z-1] [y+1] [y-1] [x+1] [x-1] " ,
function ( cmdline , pos , player )
local message = " mat: error: incompatible driver (in devel program) "
2014-06-20 09:51:45 +02:00
return message , true
2014-06-22 10:01:16 +02:00
end )
2014-06-20 09:51:45 +02:00
2014-06-22 10:01:16 +02:00
computers.register_oscommand ( " com " , " create a connexion between two computers " , " com [-c COODINATES make a connexion between this computer and an other at coordinates] \n [-p PLAYERNAME make a connexion between this computer and the closest computer to the player] " , function ( cmdline , pos , player )
local command , opt = string.match ( cmdline , " ^([^ ]+) *(%a+) " )
if opt == " -c " then
local x , y , z
command , opt , x , y , z = string.match ( cmdline , " ^([^ ]+) *(%a+) *(%d+)[, ] *(%d+)[, ] *(%d+) " )
-- ...
return command .. " : unable to connect: no network available (in devel program) "
2014-06-20 09:51:45 +02:00
else
2014-06-22 10:01:16 +02:00
local command , opt , playername = string.match ( cmdline , " ^([^ ]+) *(%a+) *(%a+) " )
local player = minetest.get_player_by_name ( playername )
local p = player.getpos ( )
-- ...
return command .. " : unable to connect: no network available (in devel program) "
2014-06-20 09:51:45 +02:00
end
2014-06-22 10:01:16 +02:00
end ) ;