1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-11-04 17:16:20 +00:00

Eta-reduce several calls to pcall

This commit is contained in:
Jonathan Coates 2020-01-15 09:29:11 +00:00
parent 8b1773dd60
commit 1db3a14c54
No known key found for this signature in database
GPG Key ID: D6D4CB5BFBBB5CB8
3 changed files with 22 additions and 25 deletions

View File

@ -991,8 +991,7 @@ if fs.exists( ".settings" ) then
end end
-- Run the shell -- Run the shell
local ok, err = pcall( function() local ok, err = pcall(parallel.waitForAny,
parallel.waitForAny(
function() function()
local sShell local sShell
if term.isColour() and settings.get( "bios.use_multishell" ) then if term.isColour() and settings.get( "bios.use_multishell" ) then
@ -1003,10 +1002,8 @@ local ok, err = pcall( function()
os.run( {}, sShell ) os.run( {}, sShell )
os.run( {}, "rom/programs/shutdown.lua" ) os.run( {}, "rom/programs/shutdown.lua" )
end, end,
function() rednet.run
rednet.run() )
end )
end )
-- If the shell errored, let the user read it. -- If the shell errored, let the user read it.
term.redirect( term.native() ) term.redirect( term.native() )

View File

@ -10,7 +10,7 @@ local bRunning = true
local tCommandHistory = {} local tCommandHistory = {}
local tEnv = { local tEnv = {
["exit"] = setmetatable({}, { ["exit"] = setmetatable({}, {
__tostring = function() return "Call exit() to exit" end, __tostring = function() return "Call exit() to exit." end,
__call = function() bRunning = false end, __call = function() bRunning = false end,
}), }),
["_echo"] = function( ... ) ["_echo"] = function( ... )

View File

@ -105,8 +105,8 @@ if sCommand == "host" then
end end
-- Handle messages -- Handle messages
local ok, error = pcall( function() local ok, error = pcall(parallel.waitForAny,
parallel.waitForAny( function() function()
while true do while true do
local _, timer = os.pullEvent( "timer" ) local _, timer = os.pullEvent( "timer" )
local nUserID = tPingPongTimer[ timer ] local nUserID = tPingPongTimer[ timer ]
@ -223,8 +223,8 @@ if sCommand == "host" then
end end
end end
end end
end ) end
end ) )
if not ok then if not ok then
printError( error ) printError( error )
end end
@ -332,8 +332,8 @@ elseif sCommand == "join" then
drawTitle() drawTitle()
local ok, error = pcall( function() local ok, error = pcall(parallel.waitForAny,
parallel.waitForAny( function() function()
while true do while true do
local sEvent, timer = os.pullEvent() local sEvent, timer = os.pullEvent()
if sEvent == "timer" then if sEvent == "timer" then
@ -402,8 +402,8 @@ elseif sCommand == "join" then
table.insert( tSendHistory, sChat ) table.insert( tSendHistory, sChat )
end end
end end
end ) end
end ) )
-- Close the windows -- Close the windows
term.redirect( parentTerm ) term.redirect( parentTerm )