1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-13 03:30:29 +00:00

Add Checks to disk,gps,help and keys

This commit is contained in:
Wilma456 2017-06-29 16:41:48 +02:00
parent 123a0158af
commit 13f886be5a
4 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,8 @@
local function isDrive( name )
if type( name ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( name ) .. ")", 3 )
end
return peripheral.getType( name ) == "drive"
end

View File

@ -56,6 +56,12 @@ local function narrow( p1, p2, fix )
end
function locate( _nTimeout, _bDebug )
if _nTimeout ~= nil and type( _nTimeout ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( _nTimeout ) .. ")", 2 )
end
if _bDebug ~= nil and type( _bDebug ) ~= "boolean" then
error( "bad argument #2 (expected boolean, got " .. type( _bDebug) .. ")", 2 )
end
-- Let command computers use their magic fourth-wall-breaking special abilities
if commands then
return commands.getBlockPosition()

View File

@ -6,10 +6,16 @@ function path()
end
function setPath( _sPath )
if type( _sPath ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sPath ) .. ")", 2 )
end
sPath = _sPath
end
function lookup( _sTopic )
if type( _sTopic ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( _sTopic ) .. ")", 2 )
end
-- Look on the path variable
for sPath in string.gmatch(sPath, "[^:]+") do
sPath = fs.combine( sPath, _sTopic )
@ -57,6 +63,9 @@ function topics()
end
function completeTopic( sText )
if type( sText ) ~= "string" then
error( "bad argument #1 (expected string, got " .. type( sText ) .. ")", 2 )
end
local tTopics = topics()
local tResults = {}
for n=1,#tTopics do

View File

@ -55,5 +55,8 @@ end
keys["return"] = keys.enter
function getName( _nKey )
if type( _nKey ) ~= "number" then
error( "bad argument #1 (expected number, got " .. type( _nKey ) .. ")", 2 )
end
return tKeys[ _nKey ]
end