updated
This commit is contained in:
@@ -1,12 +1,6 @@
|
|||||||
local maxValue = 100
|
local maxValue = 100
|
||||||
local minValue = 0
|
local minValue = 0
|
||||||
|
|
||||||
local function configureReport(monitor)
|
|
||||||
local x,y = monitor.getCursorPos()
|
|
||||||
monitor.setCursorPos(x, y + 1)
|
|
||||||
monitor.clearLine()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getValue(reactor)
|
local function getValue(reactor)
|
||||||
return (reactor.getCoolantFilledPercentage() or 0) * 100
|
return (reactor.getCoolantFilledPercentage() or 0) * 100
|
||||||
end
|
end
|
||||||
@@ -32,7 +26,6 @@ end
|
|||||||
local function report(reactor, monitor)
|
local function report(reactor, monitor)
|
||||||
local value = getValue(reactor)
|
local value = getValue(reactor)
|
||||||
local color = color(reactor)
|
local color = color(reactor)
|
||||||
configureReport(monitor)
|
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.write("Coolant: " .. value .. "%")
|
monitor.write("Coolant: " .. value .. "%")
|
||||||
end
|
end
|
||||||
|
|||||||
8
main.lua
8
main.lua
@@ -14,15 +14,19 @@ end
|
|||||||
local function runDisplay()
|
local function runDisplay()
|
||||||
monitor.clear()
|
monitor.clear()
|
||||||
monitor.setTextScale(1)
|
monitor.setTextScale(1)
|
||||||
monitor.setCursorPos(1, 1)
|
|
||||||
while true do
|
while true do
|
||||||
|
monitor.setCursorPos(1, 1)
|
||||||
|
|
||||||
local drivers = {
|
local drivers = {
|
||||||
{ Label = "Temperature", driver = tempDriver },
|
{ Label = "Temperature", driver = tempDriver },
|
||||||
{ Label = "Coolant", driver = coolantDriver },
|
{ Label = "Coolant", driver = coolantDriver },
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, item in ipairs(drivers) do
|
for i, item in ipairs(drivers) do
|
||||||
|
monitor.setCursorPos(1, i)
|
||||||
|
monitor.clearLine()
|
||||||
item.driver.report(reactor, monitor)
|
item.driver.report(reactor, monitor)
|
||||||
|
monitor.setCursorPos(1, i + 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep(0.25) -- Update every quarter second
|
sleep(0.25) -- Update every quarter second
|
||||||
|
|||||||
@@ -3,12 +3,6 @@ local function getValue(reactor)
|
|||||||
return reactor.getTemperature() or 0
|
return reactor.getTemperature() or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
local function configureReport(monitor)
|
|
||||||
local x,y = monitor.getCursorPos()
|
|
||||||
monitor.setCursorPos(x, y + 1)
|
|
||||||
monitor.clearLine()
|
|
||||||
end
|
|
||||||
|
|
||||||
local function color(reactor)
|
local function color(reactor)
|
||||||
local temperature = getValue(reactor)
|
local temperature = getValue(reactor)
|
||||||
return colors.black
|
return colors.black
|
||||||
@@ -22,7 +16,6 @@ end
|
|||||||
local function report(reactor, monitor)
|
local function report(reactor, monitor)
|
||||||
local value = getValue(reactor)
|
local value = getValue(reactor)
|
||||||
local color = color(reactor)
|
local color = color(reactor)
|
||||||
configureReport(monitor)
|
|
||||||
monitor.setBackgroundColor(color)
|
monitor.setBackgroundColor(color)
|
||||||
monitor.write("Coolant: " .. value .. "%")
|
monitor.write("Coolant: " .. value .. "%")
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user