Skip to content

Commit

Permalink
Merge pull request #304 from Wilma456/windowcheck
Browse files Browse the repository at this point in the history
Add checks to window API
  • Loading branch information
dan200 authored Jun 4, 2017
2 parents 2cd4daa + c9bf463 commit 4f3be79
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/resources/assets/computercraft/lua/rom/apis/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end

function window.setCursorBlink( blink )
if type( blink ) ~= "boolean" then
error( "Expected boolean", 2 )
end
bCursorBlink = blink
if bVisible then
updateCursorBlink()
Expand Down Expand Up @@ -302,7 +305,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
tCol[2] = g
tCol[3] = b
else
error("Expected number, number, number, number")
error( "Expected number, number, number, number", 2 )
end

if bVisible then
Expand Down Expand Up @@ -341,6 +344,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end

function window.scroll( n )
if type( n ) ~= "number" then
error( "Expected number", 2 )
end
if n ~= 0 then
local tNewLines = {}
local sEmptyText = sEmptySpaceLine
Expand Down Expand Up @@ -385,6 +391,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )

-- Other functions
function window.setVisible( bVis )
if type( bVis) ~= "boolean" then
error( "Expected boolean", 2 )
end
if bVisible ~= bVis then
bVisible = bVis
if bVisible then
Expand Down Expand Up @@ -416,6 +425,9 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
end

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
nY = nNewY
if nNewWidth and nNewHeight then
Expand Down

0 comments on commit 4f3be79

Please sign in to comment.