Posted 04 May 2018 - 08:07 PM
I am in need of help, I have searched on google and cant figure it out.
I am trying to display info on a monitor (which is working).
every time i run the program i get
its on line 140 in function getTurbineStats() I will post the code below. Everything was working until i tried to round the number.
ill try to give more info if needed.
Thanks
L4GSPike
I am trying to display info on a monitor (which is working).
every time i run the program i get
attempt to compare nil with number
its on line 140 in function getTurbineStats() I will post the code below. Everything was working until i tried to round the number.
local core = peripheral.wrap("draconic_rf_storage_4")
local turbineA = peripheral.wrap("BigReactors-Turbine_12")
local turbineB = peripheral.wrap("BigReactors-Turbine_13")
local mon = peripheral.wrap("monitor_26")
local version = "3.4"
local tier = 0
local rounded = 0
local turbineASpeed = 50
local turbineBSpeed = 50
local turbineASpeedround = 0
local turbineASpeedround = 0
local function startUpProcedure()
term.clear()
term.setCursorPos(1,1)
rs.setOutput("left", false)
print("Monitoring Power")
term.setCursorPos(18,1)
print("| Tier - " ..tier)
end
local function getInfos()
energyStored = core.getEnergyStored()
energyMax = core.getMaxEnergyStored()
turbineASpeed = turbineA.getRotorSpeed()
turbineBSpeed = turbineB.getRotorSpeed()
activeReactor = rs.getOutput("left")
end
local function displayInfos()
if energyStored < 3952000000 then --if core is less then 40% - 3952000000
rs.setOutput("left", true)
term.setCursorPos(1, 3)
print("Energy Reading ")
term.setCursorPos(1, 4)
print(energyStored)
mon.setCursorPos(1,1)
mon.setTextColor(colors.white)
mon.write("Energy Reading ")
mon.setCursorPos(1,2)
mon.write(rounded)
mon.setCursorPos(1, 3)
mon.setTextColor(colors.green)
mon.write("Reactor Status-ON")
mon.setTextColor(colors.white)
mon.setCursorPos(1, 6)
mon.write("Turbine A Speed - ")
mon.setCursorPos(1, 7)
mon.write(turbineASpeedround)
mon.setCursorPos(1,8)
mon.write("Turbine B Speed - ")
mon.setCursorPos(1,9)
mon.write(turbineBSpeedround)
elseif energyStored >= 9800000000 then --if core is 98ish% full
rs.setOutput("left", false)
term.setCursorPos(1, 3)
print("Energy Reading ")
term.setCursorPos(1, 4)
print(energyStored)
mon.setCursorPos(1,1)
mon.setTextColor(colors.white)
mon.write("Energy Reading ")
mon.setCursorPos(1,2)
mon.write(rounded)
mon.setCursorPos(1, 3)
mon.setTextColor(colors.red)
mon.write("Reactor Status-OFF")
mon.setTextColor(colors.white)
mon.setCursorPos(1, 6)
mon.write("Turbine A Speed - ")
mon.setCursorPos(1,7)
mon.write(turbineASpeedround)
mon.setCursorPos(1, 8)
mon.write("Turbine B Speed - ")
mon.setCursorPos(1,9)
mon.write(turbineBSpeedround)
else
term.setCursorPos(1, 3)
print("Energy Reading ")
term.setCursorPos(1, 4)
print(energyStored)
mon.setCursorPos(1,1)
mon.setTextColor(colors.white)
mon.write("Energy Reading")
mon.setCursorPos(1,2)
mon.write(rounded)
if activeReactor == "true" then
mon.setCursorPos(1, 3)
mon.setTextColor(colors.green)
mon.write("Reactor Status-ON")
else
mon.setCursorPos(1, 3)
mon.setTextColor(colors.red)
mon.write("Reactor Status-OFF")
end
mon.setTextColor(colors.white)
mon.setCursorPos(1, 6)
mon.write("Turbine A Speed - ")
mon.setCursorPos(1,7)
mon.write(turbineASpeedround)
mon.setCursorPos(1, 8)
mon.write("Turbine B Speed - ")
mon.setCursorPos(1,9)
mon.write(turbineBSpeedround)
end
sleep(1)
end
local function getTier() --gets tier of Draconic Core
energyMax = core.getMaxEnergyStored()
if energyMax < 50000000 then
tier = 1
elseif energyMax < 300000000 then
tier = 2
elseif energyMax < 2000000000 then
tier = 3
elseif energyMax < 10000000000 then
tier = 4
elseif energyMax < 50000000000 then
tier = 5
elseif energyMax < 400000000000 then
tier = 6
elseif energyMax < 3000000000000 then
tier = 7
else
tier = 8
end
end
local function getTurbineStats()
--if turbines are less then 100 RPM they will default to not being rounded.
if turbineASpeed > 100.00 then
turbineASpeedround = math.floor(turbineASpeed, 2)
else
turbineASpeedround = turbineASpeed
end
if turbineBSpeed > 100.00 then
turbineBSpeedround = math.floor(turbineBSpeed, 2)
else
turbineBSpeedround = turbineBSpeed
end
end
--startup (as soon as the computers booted)
getTier()
startUpProcedure()
while true do
getInfos()
getTurbineStats()
displayInfos()
end
ill try to give more info if needed.
Thanks
L4GSPike