Posted 06 November 2015 - 08:39 AM
With the term.setCursorPos its disposed to ensure the bars are centered under there header, but for example term.setCursorPos(3,5) sets the cursor to position (1,5) instead of having an x position of 3. This program is disposed to monitor a reactor and report back the status to me.
--Variables To Store Data For Later UI
local Reactor = peripheral.wrap("right")
local Con_State = false
local FuelAmmount = 0
local WasteAmmount = 0
local CoolantAmmount = 0
local SteamPressure = 0
UpdateBlock = function()
--Updates UI Display
term.clear()
term.setCursorPos(1,1)
--Prints Opening ASCII Graphics Banner
print "---------------------------------------------------"
print "|| Reactor Monitor V0.1a ||"
print "---------------------------------------------------"
term.setCursorPos(1,5)
--States Weather Reactors Active And Status Headers
print ("Active = " .. tostring(Reactor.callRemote("BigReactors-Reactor_0", "getActive")))
print ("Fuel | Waste | Cool | Steam | Temp")
--Shows Fuel Level (Max 48000)
term.setCursorPos(3,7)
for pointer=10, 0, -1 do
if Reactor.callRemote("BigReactors-Reactor_0", "getFuelAmount") >= (pointer * 4800) then
print ("#")
else
print ""
end
end
--Shows Waste Level (Max 48000)
term.setCursorPos(11,7)
for pointer=10, 0, -1 do
if Reactor.callRemote("BigReactors-Reactor_0", "getWasteAmount") >= (pointer * 4800) then
print ("#")
else
print ""
end
end
--Shows Coolant Level (Max 10000)
term.setCursorPos(19,7)
for pointer=10, 0, -1 do
if Reactor.callRemote("BigReactors-Reactor_0", "getCoolantAmount") >= (pointer * 1000) then
print ("#")
else
print ""
end
end
--Shows Steam Level (Max 10000)
term.setCursorPos(27,7)
for pointer=10, 0, -1 do
if Reactor.callRemote("BigReactors-Reactor_0", "getHotFluidAmount") >= (pointer * 1000) then
print ("#")
else
print ""
end
end
term.setCursorPos(35,7)
--Test If Reactor Heat Critical (Max I've Left Is 2800 Before Warning)
while (Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature") >= 2800) do
term.clear()
print ("WARNING REACTOR TEMPERATURE HIGH")
end
--Shows Reactor Temperature Level (Max 3000)
for pointer=10, 0, -1 do
--print (tostring(Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature")))
if ((Reactor.callRemote("BigReactors-Reactor_0", "getFuelTemperature")) >= (pointer * 300)) then
term.write("It Worked")
term.write("#")
else
print ""
end
end
end--Ensures Connection Available
Con_State = Reactor.callRemote("BigReactors-Reactor_0", "getConnected")
--Test If Connected
if (Con_State == false) then
print ("Error, Please Ensure The Reactor Is Connected")
else
--Runs Program Until Lost Connection
while ((Reactor.callRemote("BigReactors-Reactor_0", "getConnected")) == true) do
--Runs GUI Update
UpdateBlock()
sleep(5)
end
--Ends Program
term.clear()
print "Error, Can't Connect To Reactor"
end