mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-05 03:22:53 +00:00
Merge pull request #376 from CrazedProgrammer/fix-argument-checks
Fix argument checks made in PR #304 and #338
This commit is contained in:
commit
df1c8e22b8
@ -1,5 +1,8 @@
|
|||||||
|
|
||||||
function slowWrite( sText, nRate )
|
function slowWrite( sText, nRate )
|
||||||
|
if nRate ~= nil and type( nRate ) ~= "number" then
|
||||||
|
error( "bad argument #2 (expected number, got " .. type( nRate ) .. ")", 2 )
|
||||||
|
end
|
||||||
nRate = nRate or 20
|
nRate = nRate or 20
|
||||||
if nRate < 0 then
|
if nRate < 0 then
|
||||||
error( "Rate must be positive", 2 )
|
error( "Rate must be positive", 2 )
|
||||||
@ -20,7 +23,7 @@ function slowWrite( sText, nRate )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function slowPrint( sText, nRate )
|
function slowPrint( sText, nRate )
|
||||||
slowWrite( sText, nRate)
|
slowWrite( sText, nRate )
|
||||||
print()
|
print()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -329,8 +332,8 @@ function unserialize( s )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function serializeJSON( t, bNBTStyle )
|
function serializeJSON( t, bNBTStyle )
|
||||||
if type( t ) ~= "string" then
|
if type( t ) ~= "table" and type( t ) ~= "string" and type( t ) ~= "number" and type( t ) ~= "boolean" then
|
||||||
error( "bad argument #1 (expected string, got " .. type( t ) .. ")", 2 )
|
error( "bad argument #1 (expected table/string/number/boolean, got " .. type( t ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if bNBTStyle ~= nil and type( bNBTStyle ) ~= "boolean" then
|
if bNBTStyle ~= nil and type( bNBTStyle ) ~= "boolean" then
|
||||||
error( "bad argument #2 (expected boolean, got " .. type( bNBTStyle ) .. ")", 2 )
|
error( "bad argument #2 (expected boolean, got " .. type( bNBTStyle ) .. ")", 2 )
|
||||||
@ -367,7 +370,7 @@ function complete( sSearchText, tSearchTable )
|
|||||||
if type( sSearchText ) ~= "string" then
|
if type( sSearchText ) ~= "string" then
|
||||||
error( "bad argument #1 (expected string, got " .. type( sSearchText ) .. ")", 2 )
|
error( "bad argument #1 (expected string, got " .. type( sSearchText ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if type( tSearchTable ) ~= "table" then
|
if tSearchTable ~= nil and type( tSearchTable ) ~= "table" then
|
||||||
error( "bad argument #2 (expected table, got " .. type( tSearchTable ) .. ")", 2 )
|
error( "bad argument #2 (expected table, got " .. type( tSearchTable ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -413,8 +413,8 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight )
|
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight )
|
||||||
if type( nNewX ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( nNewX ) .. ")", 2 ) end
|
if type( nNewX ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( nNewX ) .. ")", 2 ) end
|
||||||
if type( nNewY ) ~= "number" then error( "bad argument #2 (expected number, got " .. type( nNewY ) .. ")", 2 ) end
|
if type( nNewY ) ~= "number" then error( "bad argument #2 (expected number, got " .. type( nNewY ) .. ")", 2 ) end
|
||||||
if type( nNewWidth ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( nNewWidth ) .. ")", 2 ) end
|
if nNewWidth ~= nil and type( nNewWidth ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( nNewWidth ) .. ")", 2 ) end
|
||||||
if type( nNewHeight ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( nNewHeight ) .. ")", 2 ) end
|
if nNewHeight ~= nil and type( nNewHeight ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( nNewHeight ) .. ")", 2 ) end
|
||||||
|
|
||||||
nX = nNewX
|
nX = nNewX
|
||||||
nY = nNewY
|
nY = nNewY
|
||||||
|
Loading…
x
Reference in New Issue
Block a user