1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-19 00:04:53 +00:00

Merge pull request #344 from Wilma456/othercheck

Add Checks to disk,gps,help and keys
This commit is contained in:
Daniel Ratcliffe 2017-06-29 16:09:46 +01:00 committed by GitHub
commit b0a2dd5eb1
4 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,8 @@
local function isDrive( name ) 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" return peripheral.getType( name ) == "drive"
end end

View File

@ -56,6 +56,12 @@ local function narrow( p1, p2, fix )
end end
function locate( _nTimeout, _bDebug ) 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 -- Let command computers use their magic fourth-wall-breaking special abilities
if commands then if commands then
return commands.getBlockPosition() return commands.getBlockPosition()

View File

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

View File

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