Posted 20 February 2017 - 04:43 AM
Hello,
So I'm attempting to make my own program to help me monitor and control my Big Reactors reactor with a custom gui made from a buttons api and progressbars api. I've made the GUI for my advanced monitors. I finally sat down to finish the code and after much learning and work i've come up with this.
I went to run it after double checking myself for typos etc. The result of my running it was a random two digit error code in red with no description. Hoping it was a random error I ran it again immediately after rechecking for typos and obvious issues. This time it returned a different two digit error code in red. Starting to get frustrated after yet again checking the code i started to spam it and noticed i got a two or three more different two digit error codes all of which have no description.
Help?!?
So I'm attempting to make my own program to help me monitor and control my Big Reactors reactor with a custom gui made from a buttons api and progressbars api. I've made the GUI for my advanced monitors. I finally sat down to finish the code and after much learning and work i've come up with this.
os.loadAPI("button")
os.loadAPI("progressbar")
progressbar.SetPeripheral("top")
reactor = peripheral.wrap("BigReactors-Reactor_0")
m = peripheral.wrap("top")
m.clear()
fuelTemp = 1
casingTemp = 1
fuel = 1
waste = 1
energy = 1
energyLT = 1
rodLevels = 0
active = false
function fillTables()
button.setTable("Power Switch", power, 10,28,3,5)
button.setTable("Up One", upOne, 4,18,7,9)
button.setTable("Up Five", upFive, 4,18,11,13)
button.setTable("Up Hundred", upHundred, 4,18,15,17)
button.setTable("Down One", downOne, 20,34,7,9)
button.setTable("Down Five", downFive, 20,34,11,13)
button.setTable("Down Hundred", downHundred, 20,34,15,17)
progressbar.SetTable("Fuel Temp", 2500, 1, 41,66,7)
progressbar.SetTable("Casing Temp", 2500, 1, 41,66,9)
progressbar.SetTable("Fuel", 700000, 1, 41,66,11)
progressbar.SetTable("Waste", 700000, 1, 41,66,13)
progressbar.SetTable("Energy Stored", 10000000, 1, 41,66,15)
progressbar.SetTable("Energy Last Tick", 42000, 1, 41,66,17)
button.screen()
progressbar.DrawToPeripheral()
end
function createLabels()
button.heading("Reactor Control Panel")
button.label(50,4, "Readings:")
button.label(39,7, "0")
button.label(50,6,"Fuel Temp")
button.label(68,7, "2.5k")
button.label(39,9, "0")
button.label(49,8,"Casing Temp")
button.label(68,9, "2.5k")
button.label(39,11, "0")
button.label(52,10,"Fuel")
button.label(68,11, "700k")
button.label(39,13,"0")
button.label(52,12,"Waste")
button.label(68,13, "700k")
button.label(39,15, "0")
button.label(48,14,"Energy Stored")
button.label(68,15, "10m")
button.label(39,17, "0")
button.label(47,16,"Energy Last Tick")
button.label(68,17, "42k")
end
function power()
active = reactor.getActive()
if active == false then
reactor.setActive(true)
active = true
button.toggleButton("Power Switch")
else
end
end
function upOne()
button.flash("Up One")
active = reactor.getActive()
if active == true then
if rodLevels <= 100 then
else
rodLevels = rodLevels + 1
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function upFive()
button.flash("Up Five")
active = reactor.getActive()
if active == true then
if rodLevels <= 100 then
else
rodLevels = rodLevels + 5
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function upHundred()
button.flash("Up Hundred")
active = reactor.getActive()
if active == true then
if rodLevels <= 100 then
else
rodLevels = rodLevels + 100
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function downOne()
button.flash("Down One")
active = reactor.getActive()
if active == true then
if rodLevels <= 0 then
else
rodLevels = rodLevels - 1
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function downFive()
button.flash("Down Five")
active = reactor.getActive()
if active == true then
if rodLevels <= 0 then
else
rodLevels = rodLevels - 5
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function downHundred()
button.flash("Down Hundred")
active = reactor.getActive()
if active == true then
if rodLevels <= 0 then
else
rodLevels = rodLevels - 100
reactor.setAllControlRodLevels(rodLevels)
end
else
end
end
function updateReadings()
progressbar.SetCurValue("Fuel Temp", fueltemp)
progressbar.SetCurValue("Casing Temp", casingtemp)
progressbar.SetCurValue("Fuel", fuel)
progressbar.SetCurValue("Waste", waste)
progressbar.SetCurValue("Energy Stored", energy)
progressbar.SetCurValue("Energy Last Tick", energyLT)
progressbar.DrawToPeripheral()
end
function getUpdatedReadings()
fuelTemp = reactor.getFuelTemperature
casingTemp = reactor.getCasingTemperature
fuel = reactor.getFuelAmount
waste = reactor.getWasteAmount
energy = reactor.getEnergyStored
energyLT = reactor.getEnergyProducedLastTick
updateReadings()
sleep(2)
end
function getClick()
event, side, x, y = os.pullEvent("monitor_touch")
button.checkxy(x,y)
end
fillTables()
createLabels()
reactor.setAllControlRodLevels(0)
reactor.setActive(false)
getUpdatedReadings()
refresh = true
while refresh do
parallel.waitForAny(getUpdatedReadings,getClick)
end
I went to run it after double checking myself for typos etc. The result of my running it was a random two digit error code in red with no description. Hoping it was a random error I ran it again immediately after rechecking for typos and obvious issues. This time it returned a different two digit error code in red. Starting to get frustrated after yet again checking the code i started to spam it and noticed i got a two or three more different two digit error codes all of which have no description.
Help?!?