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

Add checks to window API

This commit is contained in:
Wilma456 2017-06-04 12:34:40 +02:00 committed by GitHub
parent 3828750ade
commit c9bf463419

View File

@ -254,6 +254,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end end
function window.setCursorBlink( blink ) function window.setCursorBlink( blink )
if type( blink ) ~= "boolean" then
error( "Expected boolean", 2 )
end
bCursorBlink = blink bCursorBlink = blink
if bVisible then if bVisible then
updateCursorBlink() updateCursorBlink()
@ -302,7 +305,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
tCol[2] = g tCol[2] = g
tCol[3] = b tCol[3] = b
else else
error("Expected number, number, number, number") error( "Expected number, number, number, number", 2 )
end end
if bVisible then if bVisible then
@ -341,6 +344,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end end
function window.scroll( n ) function window.scroll( n )
if type( n ) ~= "number" then
error( "Expected number", 2 )
end
if n ~= 0 then if n ~= 0 then
local tNewLines = {} local tNewLines = {}
local sEmptyText = sEmptySpaceLine local sEmptyText = sEmptySpaceLine
@ -385,6 +391,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
-- Other functions -- Other functions
function window.setVisible( bVis ) function window.setVisible( bVis )
if type( bVis) ~= "boolean" then
error( "Expected boolean", 2 )
end
if bVisible ~= bVis then if bVisible ~= bVis then
bVisible = bVis bVisible = bVis
if bVisible then if bVisible then
@ -416,6 +425,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end end
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight ) function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight )
if type( nNewX ) ~= "number" or type( nNewY ) ~= "number" or type( nNewWidth ) ~= "number" or type( nNewWidth ) ~= "number" then
error( "Expected number, number, number, number", 2 )
end
nX = nNewX nX = nNewX
nY = nNewY nY = nNewY
if nNewWidth and nNewHeight then if nNewWidth and nNewHeight then