Posted 12 January 2015 - 10:03 PM
Hi, so i'm just writing a small script to display big reactor information in the form of bars like
the controller does. It works as intended on first run but does not update the information at
all afterwards. not sure what i have done wrong.
Thanks in advance for any help.
the controller does. It works as intended on first run but does not update the information at
all afterwards. not sure what i have done wrong.
reactor=peripheral.wrap('BigReactors-Reactor_0')
monitor=peripheral.wrap('monitor_1')
--Grab
Fuel=math.floor(((reactor.getFuelAmount()/reactor.getFuelAmountMax())*100)+0.5)
Waste=math.floor(((reactor.getWasteAmount()/reactor.getFuelAmountMax())*100)+0.5)
storedenergy=math.floor(((reactor.getEnergyStored()/10000000)*100)+0.5)
monitor.setTextScale(1)
monitor.setBackgroundColor(colors.black)
--Create Each bar here, to save us time--
function CreateBar(full, hP, vP)
monitor.setCursorPos(hP,vP)
monitor.setBackgroundColor(colors.black)
monitor.setTextColor(colors.white)
if full then
monitor.setBackgroundColor(colors.yellow)
monitor.setTextColor(colors.black)
monitor.write('_____')
monitor.setBackgroundColor(colors.black)
monitor.write('_')
else
monitor.write('')
end
end
--Lets get crackin' ey--
while true do
monitor.clear()
monitor.setCursorPos(1,1)
monitor.setTextColor(colors.black)
--10 bars, 10 increments--
for i=1, tonumber(10) do
if Fuel >= i*10 then
CreateBar(true, 2, 11-i)
else
CreateBar(false, 2, 11-i)
end
if storedenergy >= i*10 then
CreateBar(true, 8, 11-i)
else
CreateBar(false, 8, 11-i)
end
monitor.setTextColor(colors.black)
end
monitor.setCursorPos(3,11)
monitor.setTextColor(colors.yellow)
monitor.write(Fuel..'%')
monitor.setCursorPos(9,11)
monitor.setTextColor(colors.red)
monitor.write(storedenergy..'%')
monitor.setTextColor(colors.black)
sleep(3)
end
Thanks in advance for any help.