Skip to content

Commit 1774f1a

Browse files
committed
Merge pull request dan200#566 from SquidDev-CC/ComputerCraft/feature/tiny-lua-wins
A couple of small improvements to CraftOS
2 parents 0931325 + de13079 commit 1774f1a

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

src/main/resources/assets/computercraft/lua/bios.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ if _VERSION == "Lua 5.1" then
1818
if env ~= nil and type( env) ~= "table" then
1919
error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 )
2020
end
21-
if mode ~= nil and mode ~= "t" then
22-
error( "Binary chunk loading prohibited", 2 )
23-
end
2421
local ok, p1, p2 = pcall( function()
2522
if type(x) == "string" then
2623
local result, err = nativeloadstring( x, name )

src/main/resources/assets/computercraft/lua/rom/apis/window.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,10 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
421421
function window.reposition( nNewX, nNewY, nNewWidth, nNewHeight )
422422
if type( nNewX ) ~= "number" then error( "bad argument #1 (expected number, got " .. type( nNewX ) .. ")", 2 ) end
423423
if type( nNewY ) ~= "number" then error( "bad argument #2 (expected number, got " .. type( nNewY ) .. ")", 2 ) end
424-
if nNewWidth ~= nil and type( nNewWidth ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( nNewWidth ) .. ")", 2 ) end
425-
if nNewHeight ~= nil and type( nNewHeight ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( nNewHeight ) .. ")", 2 ) end
424+
if nNewWidth ~= nil or nNewWidth ~= nil then
425+
if type( nNewWidth ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( nNewWidth ) .. ")", 2 ) end
426+
if type( nNewHeight ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( nNewHeight ) .. ")", 2 ) end
427+
end
426428

427429
nX = nNewX
428430
nY = nNewY

src/main/resources/assets/computercraft/lua/rom/programs/help.lua

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,14 @@ if sTopic == "index" then
1313
return
1414
end
1515

16-
local w,h = term.getSize()
1716
local sFile = help.lookup( sTopic )
1817
local file = ((sFile ~= nil) and io.open( sFile )) or nil
19-
local nLinesPrinted = 0
2018
if file then
21-
local sLine = file:read()
22-
local nLines = 0
23-
while sLine do
24-
nLines = nLines + textutils.pagedPrint( sLine, (h-3) - nLines )
25-
sLine = file:read()
26-
end
19+
local sContents = file:read("*a")
2720
file:close()
21+
22+
local _, nHeight = term.getSize()
23+
textutils.pagedPrint( sContents, nHeight - 3 )
2824
else
2925
print( "No help available" )
3026
end

src/main/resources/assets/computercraft/lua/rom/programs/http/pastebin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ elseif sCommand == "run" then
113113
printError( err )
114114
return
115115
end
116-
local success, msg = pcall(func, table.unpack(tArgs, 3))
116+
local success, msg = pcall(func, select(3, ...))
117117
if not success then
118118
printError( msg )
119119
end

src/main/resources/assets/computercraft/lua/rom/programs/turtle/dance.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,18 +89,17 @@ end
8989

9090
print( "Press any key to stop the groove" )
9191

92-
local bEnd = false
93-
parallel.waitForAll(
92+
parallel.waitForAny(
9493
function()
9594
while not bEnd do
9695
local event, key = os.pullEvent("key")
9796
if key ~= keys.escape then
98-
bEnd = true
97+
return
9998
end
10099
end
101100
end,
102101
function()
103-
while not bEnd do
102+
while true do
104103
local fnMove = tMoves[math.random(1,#tMoves)]
105104
fnMove()
106105
end

0 commit comments

Comments
 (0)