Posted 17 June 2014 - 05:55 PM
I have been attempting to create a BigReactor control monitor for my single player and my program is not running a function when called. the reactor setup is over the wired modem. the setup assumes a computer connected to a (5x3)monitor via wire and a reactor with five control rods named 1 - 5 connected via wire.
please suggest fixes.
please suggest fixes.
--setup
local disp = peripheral.wrap("monitor_0")
local reac = peripheral.wrap("BigReactors-Reactor_0")
disp.clear()
disp.write("Reactor booting up")
disp.setCursorPos(1,1)
print(os.getComputerLabel().."has started.")
if reac.getActive() then reac.setActive(false) end
--Button and Nameplate Lists
power = {x = 2,y = 2,lx = 7,ly = 0,c = colors.yellow,n = " Power "}
rod1 = {x = 10,y = 2,lx = 3,ly = 0,c = colors.orange,n = " 1 "}
rod2 = {x = 14,y = 2,lx = 3,ly = 0,c = colors.orange,n = " 2 "}
rod3 = {x = 18,y = 2,lx = 3,ly = 0,c = colors.orange,n = " 3 "}
rod4 = {x = 22,y = 2,lx = 3,ly = 0,c = colors.orange,n = " 4 "}
rod5 = {x = 26,y = 2,lx = 3,ly = 0,c = colors.orange,n = " 5 "}
rodAll = {x = 30,y = 2,lx = 5,ly = 0,c = colors.orange,n = " All "}
rod1Up = {x = 10,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rod1Do = {x = 10,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
rod2Up = {x = 14,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rod2Do = {x = 14,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
rod3Up = {x = 18,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rod3Do = {x = 18,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
rod4Up = {x = 22,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rod4Do = {x = 22,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
rod5Up = {x = 26,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rod5Do = {x = 26,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
rodAllUp = {x = 31,y = 3,lx = 3,ly = 0,c = colors.orange,n = "^^^"}
rodAllDo = {x = 31,y = 18,lx = 3,ly = 0,c = colors.orange,n = "vvv"}
temp = {x = 36,y = 2,lx = 6,ly = 0,c = colors.red,n = " Temp "}
cool = {x = 44,y = 2,lx = 6,ly = 0,c = colors.blue,n = " Cool "}
names = {power,rod1,rod2,rod3,rod4,rod5,rodAll,temp,cool,rod1Up,rod1Do,rod2Up,rod2Do,rod3Up,rod3Do,rod4Up,rod4Do,rod5Up,rod5Do,rodAllUp,rodAllDo}
--Bars
bars = {bfuel,brod1,brod2,brod3,brod4,brod5,brodAll,btemp}
bfuel = {x1 = 2,y1 = 3,x2 = 7,y2 = 18,c = colors.yellow}
brod1 = {x = 10,y1 = 3,x2 = 13,y2 = 18,c = colors.grey}
brod2 = {x = 14,y1 = 3,x2 = 17,y2 = 18,c = colors.grey}
brod3 = {x = 18,y1 = 3,x2 = 21,y2 = 18,c = colors.grey}
brod4 = {x = 22,y1 = 3,x2 = 25,y2 = 18,c = colors.grey}
brod5 = {x = 26,y1 = 3,x2 = 29,y2 = 18,c = colors.grey}
brodAll = {x = 31,y1 = 3,x2 = 36,y2 = 18,c = colors.grey}
btemp = {x1 = 36,y1 = 2,x2 = 43,y2 = 18,c = colors.red}
function barUpdate()
print('barUpdate')
bfuel.dark,a = math.modf(((reactor.fuel/reac.getFuelAmountMax())/15)*100)
brod1.dark,a = math.modf((reactor.rod1/14))
brod2.dark,a = math.modf((reactor.rod2/14))
brod3.dark,a = math.modf((reactor.rod3/14))
brod4.dark,a = math.modf((reactor.rod4/14))
brod5.dark,a = math.modf((reactor.rod5/14))
brodAll.dark,a = math.modf((reactor.rodAll/14))
btemp.dark,a = reactor.caseTemp/1
print('')
end
function drawBar()
term.redirect(disp)
for I = 1,#bars do
local b = bars[I]
print('barDraw')
print(B)/>/>
print(b.x1)
print(b.y1)
print(b.x2)
print(b.y2)
print(b.c)
print(b.dark)
print('')
paintutils.drawLine(b.x2,b.y2,b.x1,b.y1-b.dark,b.c)
end
term.redirect(term.native())
end
--[[function barDraw()
for I = 1,#bars do
local b = bars[I]
disp.setBackgroundColor(b.c)
--print entire bar
for y = b.y1,b.y2 do
disp.setCursorPos(b.x,y)
disp.write(string.rep(" ",b.x2-b.x1))
end
--erase part
disp.setBackGroundColor(colors.black)
for y = b.y1,(b.y1+b.dark) do
for x = b.x1,b.x2 do
disp.setCursorPos(x,y)
disp.write(" ")
end
end
end
end]]--
reactor = {}
function updateReactor()
--List containing relevant info
reactor.active = reac.getActive()
reactor.caseTemp = reac.getCasingTemperature()
reactor.rod1 = reac.getControlRodLevel(0)
reactor.rod2 = reac.getControlRodLevel(1)
reactor.rod3 = reac.getControlRodLevel(2)
reactor.rod4 = reac.getControlRodLevel(3)
reactor.rod5 = reac.getControlRodLevel(4)
print('updateReactor')
print(reactor.rod1)
print(reactor.rod2)
print(reactor.rod3)
print(reactor.rod4)
print(reactor.rod5)
print(reactor.caseTemp)
print(reactor.rodAll)
print('')
reactor.rodAll = (reactor.rod1+reactor.rod2+reactor.rod3+reactor.rod4+reactor.rod5)/5
reactor.cool = reac.getCoolantAmount()
reactor.fuel = reac.getFuelAmount()
end
function drawBox()
for i = 1,#names do
b = names[i]
disp.setBackgroundColor(b.c)
for T = 0,b.ly do disp.setCursorPos(b.x,b.y+T)
for E = 1,b.lx do
disp.write(" ")
end
end
disp.setCursorPos(b.x,b.y)
disp.setTextColor(colors.white)
disp.write(b.n)
end
disp.setBackgroundColor(colors.black)
disp.write(" ")
end
disp.clear()
drawBox()
while true do --My main loop (just running display currently)
updateReactor()
barUpdate()
drawBar() -- this is the function I have issues with
sleep(2)
end