Reactor monitor handling

Integrated default LUA script for monitor handling
This commit is contained in:
LemADEC 2014-08-25 03:13:44 +02:00
parent 29a16fc42d
commit 84546c2984

View file

@ -1,4 +1,4 @@
monitor_textScale = 1.0 monitor_textScale = 0.5
Style = { Style = {
CDefault = colors.white, CDefault = colors.white,
@ -92,7 +92,7 @@ end
function WriteCentered(y, text) function WriteCentered(y, text)
SetCursorPos((51 - text:len()) / 2, y) SetCursorPos((51 - text:len()) / 2, y)
Write(text) term.write(text)
if monitors ~= nil then if monitors ~= nil then
for key,monitor in pairs(monitors) do for key,monitor in pairs(monitors) do
sizeX, sizeY = monitor.getSize() sizeX, sizeY = monitor.getSize()
@ -429,8 +429,10 @@ if not label then
end end
-- initial scanning -- initial scanning
monitors = {}
Clear() Clear()
ShowTitle(label .. " - Connecting...") ShowTitle(label .. " - Connecting...")
WriteLn("")
sides = peripheral.getNames() sides = peripheral.getNames()
reactor = nil reactor = nil
@ -440,24 +442,30 @@ cloakingcores = {}
warpcore = nil warpcore = nil
for key,side in pairs(sides) do for key,side in pairs(sides) do
sleep(0) sleep(0)
if peripheral.getType(side) == "monitor" then
WriteLn("Wrapping " .. side)
lmonitor = peripheral.wrap(side)
table.insert(monitors, lmonitor)
lmonitor.setTextScale(monitor_textScale)
end
if peripheral.getType(side) == "warpcore" then if peripheral.getType(side) == "warpcore" then
print("Wrapping " .. side) WriteLn("Wrapping " .. side)
warpcore = peripheral.wrap(side) warpcore = peripheral.wrap(side)
end end
if peripheral.getType(side) == "warpdriveReactor" then if peripheral.getType(side) == "warpdriveReactor" then
print("Wrapping " .. side) WriteLn("Wrapping " .. side)
reactor = peripheral.wrap(side) reactor = peripheral.wrap(side)
end end
if peripheral.getType(side) == "warpdriveReactorLaser" then if peripheral.getType(side) == "warpdriveReactorLaser" then
print("Wrapping " .. side) WriteLn("Wrapping " .. side)
table.insert(reactorlasers, peripheral.wrap(side)) table.insert(reactorlasers, peripheral.wrap(side))
end end
if peripheral.getType(side) == "mininglaser" then if peripheral.getType(side) == "mininglaser" then
print("Wrapping " .. side) WriteLn("Wrapping " .. side)
table.insert(mininglasers, peripheral.wrap(side)) table.insert(mininglasers, peripheral.wrap(side))
end end
if peripheral.getType(side) == "cloakingdevicecore" then if peripheral.getType(side) == "cloakingdevicecore" then
print("Wrapping " .. side) WriteLn("Wrapping " .. side)
table.insert(cloakingcores, peripheral.wrap(side)) table.insert(cloakingcores, peripheral.wrap(side))
end end
end end
@ -470,6 +478,17 @@ function connections_page()
ShowTitle(label .. " - Connections") ShowTitle(label .. " - Connections")
WriteLn("") WriteLn("")
if #monitors == 0 then
SetColorDisabled()
WriteLn("No Monitor detected")
elseif #monitors == 1 then
SetColorSuccess()
WriteLn("1 monitor detected")
else
SetColorSuccess()
WriteLn(#monitors .. " Monitors detected")
end
if warpcore == nil then if warpcore == nil then
SetColorDisabled() SetColorDisabled()
WriteLn("No warpcore controller detected") WriteLn("No warpcore controller detected")
@ -665,10 +684,10 @@ function reactor_page()
Write("rated at " .. reactor_rate .. " RF") Write("rated at " .. reactor_rate .. " RF")
end end
SetColorDefault() SetColorDefault()
SetCursorPos(1, 12) SetCursorPos( 1, 12)
Write("Target stability: " .. reactor_targetStability .. "%") Write("Target stability: " .. reactor_targetStability .. "%")
SetCursorPos(1, 13) SetCursorPos(30, 12)
Write("Laser amount : " .. reactor_energyLevel) Write("Laser amount: " .. reactor_energyLevel)
SetColorTitle() SetColorTitle()
SetCursorPos(1, 14) SetCursorPos(1, 14)