Fixed various LUA scripts inconsistencies
- propagate robustness fixes - remove lua extension from OC files - fix display glitch in reactor output rate - code cleanup
This commit is contained in:
parent
4c51624cb2
commit
72c83af746
24 changed files with 74 additions and 60 deletions
|
@ -11,7 +11,7 @@ local lhc_parameters = {}
|
|||
local accelerator = nil
|
||||
|
||||
function lhc_boot(isDetailed)
|
||||
if accelerator == nil then
|
||||
if accelerator == nil or accelerator.interfaced() == nil then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -369,7 +369,7 @@ function connections_page(isBooting)
|
|||
w.writeLn(#monitors .. " Monitors detected")
|
||||
end
|
||||
|
||||
if accelerator == nil then
|
||||
if accelerator == nil or accelerator.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No accelerator controller detected")
|
||||
else
|
||||
|
|
|
@ -14,7 +14,7 @@ for _, side in pairs(sides) do
|
|||
end
|
||||
|
||||
|
||||
if cloakingCore == nil then
|
||||
if cloakingcore == nil or cloakingcore.interfaced() == nil then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No cloaking core detected")
|
||||
|
|
|
@ -14,7 +14,7 @@ for _, side in pairs(sides) do
|
|||
end
|
||||
|
||||
|
||||
if cloakingCore == nil then
|
||||
if cloakingcore == nil or cloakingcore.interfaced() == nil then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No cloaking core detected")
|
||||
|
|
|
@ -14,7 +14,7 @@ for _, side in pairs(sides) do
|
|||
end
|
||||
|
||||
|
||||
if cloakingCore == nil then
|
||||
if cloakingcore == nil or cloakingcore.interfaced() == nil then
|
||||
term.setBackgroundColor(colors.red)
|
||||
term.setTextColor(colors.white)
|
||||
term.write("No cloaking core detected")
|
||||
|
|
|
@ -94,7 +94,7 @@ function reactor_page()
|
|||
w.page_begin(w.data_getName() .. " - Reactor status")
|
||||
|
||||
w.setCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.write("Reactor not detected")
|
||||
else
|
||||
|
@ -259,7 +259,7 @@ end
|
|||
local reactor_configPageLoaded = false
|
||||
function reactor_pulse(output)
|
||||
reactor_output = output
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.reboot()
|
||||
end
|
||||
local instabilities = { reactor.instability() }
|
||||
|
@ -287,7 +287,7 @@ function reactor_pulse(output)
|
|||
end
|
||||
if energy[3] ~= nil then
|
||||
w.setCursorPos(12, 8)
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
end
|
||||
|
||||
if #reactorlasers ~= 0 then
|
||||
|
@ -319,7 +319,7 @@ function reactor_config()
|
|||
w.page_begin(w.data_getName() .. " - Reactor configuration")
|
||||
|
||||
w.setCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.write("Reactor not detected")
|
||||
else
|
||||
|
@ -380,7 +380,7 @@ function connections_page(isBooting)
|
|||
w.writeLn(#monitors .. " Monitors detected")
|
||||
end
|
||||
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No Enantiomorphic reactor detected")
|
||||
else
|
||||
|
|
|
@ -468,7 +468,7 @@ function cloaking_page()
|
|||
if #cloakingcores == 0 then
|
||||
SetColorDisabled()
|
||||
Write("No cloaking core detected...")
|
||||
elseif cloakingcore == nil then
|
||||
elseif cloakingcore == nil or cloakingcore.interfaced() == nil then
|
||||
SetColorWarning()
|
||||
Write("Cloaking core " .. cloaking_currentKey .. " of " .. #cloakingcores .. " is invalid")
|
||||
else
|
||||
|
@ -602,7 +602,7 @@ function mining_page()
|
|||
if #mininglasers == 0 then
|
||||
SetColorDisabled()
|
||||
Write("No mining laser detected...")
|
||||
elseif mininglaser == nil then
|
||||
elseif mininglaser == nil or mininglaser.interfaced() == nil then
|
||||
SetColorWarning()
|
||||
Write("Mining laser " .. mining_currentKey .. " of " .. #mininglasers .. " is invalid")
|
||||
else
|
||||
|
@ -1226,7 +1226,7 @@ function reactor_page()
|
|||
ShowTitle(label .. " - Reactor status")
|
||||
|
||||
SetCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
Write("Reactor not detected")
|
||||
else
|
||||
|
@ -1388,7 +1388,7 @@ end
|
|||
local reactor_configPageLoaded = false
|
||||
function reactor_pulse(output)
|
||||
reactor_output = output
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
os.reboot()
|
||||
end
|
||||
local instabilities = { reactor.instability() }
|
||||
|
@ -1451,7 +1451,7 @@ function reactor_config()
|
|||
ShowTitle(label .. " - Reactor configuration")
|
||||
|
||||
SetCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
Write("Reactor not detected")
|
||||
else
|
||||
|
@ -1592,7 +1592,7 @@ function radar_page()
|
|||
ShowTitle(label .. " - Radar map")
|
||||
|
||||
SetCursorPos(1, 2)
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
Write("Radar not detected")
|
||||
else
|
||||
|
@ -1661,7 +1661,7 @@ function radar_page_config()
|
|||
ShowTitle(label .. " - Radar configuration")
|
||||
|
||||
SetCursorPos(1, 2)
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
Write("No radar detected")
|
||||
else
|
||||
|
@ -1720,7 +1720,7 @@ end
|
|||
|
||||
function radar_scan()
|
||||
local monitor = radar_getMonitor()
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
draw_warning(monitor, "No radar")
|
||||
return false
|
||||
end
|
||||
|
@ -2008,7 +2008,7 @@ function connections_page()
|
|||
WriteLn(#monitors .. " Monitors detected")
|
||||
end
|
||||
|
||||
if ship == nil then
|
||||
if ship == nil or ship.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
WriteLn("No ship controller detected")
|
||||
else
|
||||
|
@ -2016,7 +2016,7 @@ function connections_page()
|
|||
WriteLn("Ship controller detected")
|
||||
end
|
||||
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
WriteLn("No Enantiomorphic reactor detected")
|
||||
else
|
||||
|
@ -2057,7 +2057,7 @@ function connections_page()
|
|||
WriteLn(#cloakingcores .. " cloaking cores detected")
|
||||
end
|
||||
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
SetColorDisabled()
|
||||
WriteLn("No radar detected")
|
||||
else
|
||||
|
|
|
@ -25,7 +25,7 @@ for key,side in pairs(sides) do
|
|||
radar = peripheral.wrap(side)
|
||||
end
|
||||
end
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
showErrorAndExit("No radar detected")
|
||||
end
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ for _, side in pairs(sides) do
|
|||
radar = peripheral.wrap(side)
|
||||
end
|
||||
end
|
||||
if radar == nil then
|
||||
if radar == nil or radar.interfaced() == nil then
|
||||
showErrorAndExit("No radar detected")
|
||||
end
|
||||
|
||||
|
|
|
@ -664,7 +664,7 @@ function connections_page(isBooting)
|
|||
w.writeLn(#monitors .. " Monitors detected")
|
||||
end
|
||||
|
||||
if ship == nil then
|
||||
if ship == nil or ship.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No ship controller detected")
|
||||
else
|
||||
|
@ -700,16 +700,23 @@ w.page_register('3', ship_page_navigation, ship_key_navigation)
|
|||
ship_register()
|
||||
|
||||
w.boot()
|
||||
w.run()
|
||||
|
||||
if data.ship_summon then
|
||||
data.ship_summon = false
|
||||
w.data_save()
|
||||
end
|
||||
|
||||
if ship ~= nil then
|
||||
ship.command("OFFLINE")
|
||||
ship.enable(false)
|
||||
end
|
||||
|
||||
w.close()
|
||||
local success, message = pcall(w.run)
|
||||
if not success then
|
||||
print("failed with message")
|
||||
print(message)
|
||||
w.sleep(3.0)
|
||||
print("rebooting...")
|
||||
w.reboot()
|
||||
else
|
||||
if data.ship_summon then
|
||||
data.ship_summon = false
|
||||
w.data_save()
|
||||
end
|
||||
|
||||
if ship ~= nil then
|
||||
ship.command("OFFLINE")
|
||||
ship.enable(false)
|
||||
end
|
||||
|
||||
w.close()
|
||||
end
|
|
@ -515,7 +515,7 @@ function laser_station_page()
|
|||
w.write(w.format_integer(camVideoChannel, 5))
|
||||
w.setColorNormal()
|
||||
w.write(" @ " .. w.format_integer(camX, 7) .. " " .. w.format_integer(camY, 3) .. " " .. w.format_integer(camZ, 7)
|
||||
.. " " .. w.format_address(laserstation.cameraAddress, 10, 100))
|
||||
.. " " .. w.format_address(laserstation.cameraAddress))
|
||||
end
|
||||
|
||||
w.setCursorPos(1, 5)
|
||||
|
|
|
@ -10,7 +10,7 @@ local lhc_parameters = {}
|
|||
local accelerator = nil
|
||||
|
||||
function lhc_boot(isDetailed)
|
||||
if accelerator == nil then
|
||||
if accelerator == nil or accelerator.interfaced() == nil then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -356,7 +356,7 @@ function connections_page(isBooting)
|
|||
|
||||
w.writeLn("")
|
||||
|
||||
if accelerator == nil then
|
||||
if accelerator == nil or accelerator.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No accelerator controller detected")
|
||||
else
|
||||
|
|
|
@ -93,7 +93,7 @@ function reactor_page()
|
|||
w.page_begin(w.data_getName() .. " - Reactor status")
|
||||
|
||||
w.setCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.write("Reactor not detected")
|
||||
else
|
||||
|
@ -259,7 +259,7 @@ local reactor_configPageLoaded = false
|
|||
local reactor_pulseStep = 0
|
||||
function reactor_pulse(output)
|
||||
reactor_output = output
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.reboot()
|
||||
end
|
||||
local instabilities = { reactor.instability() }
|
||||
|
@ -290,7 +290,7 @@ function reactor_pulse(output)
|
|||
end
|
||||
if energy[3] ~= nil then
|
||||
w.setCursorPos(12, 8)
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
w.write(energy[3] .. " RF/t ")
|
||||
end
|
||||
|
||||
elseif reactor_pulseStep == 4 then
|
||||
|
@ -324,7 +324,7 @@ function reactor_config()
|
|||
w.page_begin(w.data_getName() .. " - Reactor configuration")
|
||||
|
||||
w.setCursorPos(1, 2)
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.write("Reactor not detected")
|
||||
else
|
||||
|
@ -373,7 +373,7 @@ function connections_page(isBooting)
|
|||
|
||||
w.writeLn("")
|
||||
|
||||
if reactor == nil then
|
||||
if reactor == nil or reactor.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No Enantiomorphic reactor detected")
|
||||
else
|
||||
|
|
|
@ -60,7 +60,7 @@ until (count ~= nil and count ~= -1) or delay > 10
|
|||
|
||||
if count ~= nil and count > 0 then
|
||||
for i=0, count-1 do
|
||||
success, type, name, x, y, z = radar.getResult(i)
|
||||
local success, type, name, x, y, z = radar.getResult(i)
|
||||
if success then
|
||||
print(type .. " " .. name .. " @ (" .. x .. " " .. y .. " " .. z .. ")")
|
||||
else
|
|
@ -656,7 +656,7 @@ function connections_page(isBooting)
|
|||
|
||||
w.writeLn("")
|
||||
|
||||
if ship == nil then
|
||||
if ship == nil or ship.interfaced() == nil then
|
||||
w.setColorDisabled()
|
||||
w.writeLn("No ship controller detected")
|
||||
else
|
||||
|
@ -692,16 +692,23 @@ w.page_register('3', ship_page_navigation, ship_key_navigation)
|
|||
ship_register()
|
||||
|
||||
w.boot()
|
||||
w.run()
|
||||
|
||||
if data.ship_summon then
|
||||
data.ship_summon = false
|
||||
w.data_save()
|
||||
end
|
||||
|
||||
if ship ~= nil then
|
||||
ship.command("OFFLINE")
|
||||
ship.enable(false)
|
||||
end
|
||||
|
||||
w.close()
|
||||
local success, message = pcall(w.run)
|
||||
if not success then
|
||||
print("failed with message")
|
||||
print(message)
|
||||
w.sleep(3.0)
|
||||
print("rebooting...")
|
||||
w.reboot()
|
||||
else
|
||||
if data.ship_summon then
|
||||
data.ship_summon = false
|
||||
w.data_save()
|
||||
end
|
||||
|
||||
if ship ~= nil then
|
||||
ship.command("OFFLINE")
|
||||
ship.enable(false)
|
||||
end
|
||||
|
||||
w.close()
|
||||
end
|
Loading…
Reference in a new issue