mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-04-29 14:13:13 +00:00
A couple of small improvements to CraftOS
- Make window.reposition's argument validation a little more strict. Previously it would accept `window.reposition(x, y, width)` (no height argument), just not act upon it. - Use select instead of table.unpack within `pastebin run`. - Use `parallel.waitForAny` instead of `waitForAll` within the dance program. - Pipe the entire help file into `textutils.pagedPrint`, rather than doing it line by line. - Remove bytecode loading disabling from bios.lua. This never worked correctly, and serves little purpose as LuaJ is not vulnerable to such exploits.
This commit is contained in:
parent
914df8b0c7
commit
de1307913b
@ -18,9 +18,6 @@ if _VERSION == "Lua 5.1" then
|
|||||||
if env ~= nil and type( env) ~= "table" then
|
if env ~= nil and type( env) ~= "table" then
|
||||||
error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 )
|
error( "bad argument #4 (expected table, got " .. type( env ) .. ")", 2 )
|
||||||
end
|
end
|
||||||
if mode ~= nil and mode ~= "t" then
|
|
||||||
error( "Binary chunk loading prohibited", 2 )
|
|
||||||
end
|
|
||||||
local ok, p1, p2 = pcall( function()
|
local ok, p1, p2 = pcall( function()
|
||||||
if type(x) == "string" then
|
if type(x) == "string" then
|
||||||
local result, err = nativeloadstring( x, name )
|
local result, err = nativeloadstring( x, name )
|
||||||
|
@ -421,8 +421,10 @@ 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 nNewWidth ~= nil and type( nNewWidth ) ~= "number" then error( "bad argument #3 (expected number, got " .. type( nNewWidth ) .. ")", 2 ) end
|
if nNewWidth ~= nil or nNewWidth ~= nil then
|
||||||
if nNewHeight ~= nil and type( nNewHeight ) ~= "number" then error( "bad argument #4 (expected number, got " .. type( nNewHeight ) .. ")", 2 ) end
|
if 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
|
||||||
|
end
|
||||||
|
|
||||||
nX = nNewX
|
nX = nNewX
|
||||||
nY = nNewY
|
nY = nNewY
|
||||||
|
@ -13,18 +13,14 @@ if sTopic == "index" then
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local w,h = term.getSize()
|
|
||||||
local sFile = help.lookup( sTopic )
|
local sFile = help.lookup( sTopic )
|
||||||
local file = ((sFile ~= nil) and io.open( sFile )) or nil
|
local file = ((sFile ~= nil) and io.open( sFile )) or nil
|
||||||
local nLinesPrinted = 0
|
|
||||||
if file then
|
if file then
|
||||||
local sLine = file:read()
|
local sContents = file:read("*a")
|
||||||
local nLines = 0
|
|
||||||
while sLine do
|
|
||||||
nLines = nLines + textutils.pagedPrint( sLine, (h-3) - nLines )
|
|
||||||
sLine = file:read()
|
|
||||||
end
|
|
||||||
file:close()
|
file:close()
|
||||||
|
|
||||||
|
local _, nHeight = term.getSize()
|
||||||
|
textutils.pagedPrint( sContents, nHeight - 3 )
|
||||||
else
|
else
|
||||||
print( "No help available" )
|
print( "No help available" )
|
||||||
end
|
end
|
||||||
|
@ -113,7 +113,7 @@ elseif sCommand == "run" then
|
|||||||
printError( err )
|
printError( err )
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local success, msg = pcall(func, table.unpack(tArgs, 3))
|
local success, msg = pcall(func, select(3, ...))
|
||||||
if not success then
|
if not success then
|
||||||
printError( msg )
|
printError( msg )
|
||||||
end
|
end
|
||||||
|
@ -89,18 +89,17 @@ end
|
|||||||
|
|
||||||
print( "Press any key to stop the groove" )
|
print( "Press any key to stop the groove" )
|
||||||
|
|
||||||
local bEnd = false
|
parallel.waitForAny(
|
||||||
parallel.waitForAll(
|
|
||||||
function()
|
function()
|
||||||
while not bEnd do
|
while not bEnd do
|
||||||
local event, key = os.pullEvent("key")
|
local event, key = os.pullEvent("key")
|
||||||
if key ~= keys.escape then
|
if key ~= keys.escape then
|
||||||
bEnd = true
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
while not bEnd do
|
while true do
|
||||||
local fnMove = tMoves[math.random(1,#tMoves)]
|
local fnMove = tMoves[math.random(1,#tMoves)]
|
||||||
fnMove()
|
fnMove()
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user