1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 14:43:22 +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,22 +991,19 @@ if fs.exists( ".settings" ) then
end
-- Run the shell
local ok, err = pcall( function()
parallel.waitForAny(
function()
local sShell
if term.isColour() and settings.get( "bios.use_multishell" ) then
sShell = "rom/programs/advanced/multishell.lua"
else
sShell = "rom/programs/shell.lua"
end
os.run( {}, sShell )
os.run( {}, "rom/programs/shutdown.lua" )
end,
function()
rednet.run()
end )
end )
local ok, err = pcall(parallel.waitForAny,
function()
local sShell
if term.isColour() and settings.get( "bios.use_multishell" ) then
sShell = "rom/programs/advanced/multishell.lua"
else
sShell = "rom/programs/shell.lua"
end
os.run( {}, sShell )
os.run( {}, "rom/programs/shutdown.lua" )
end,
rednet.run
)
-- If the shell errored, let the user read it.
term.redirect( term.native() )

View File

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

View File

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