thanks in advance for your help much appreciated
ps my code is ugly and long for nothing and dirty coding for i am learning but it still works :D/>
--Peripheral Wrapping--
mon = peripheral.wrap("monitor_0")
r = peripheral.wrap("BigReactors-Reactor_0")
t = peripheral.wrap("BigReactors-Turbine_0")
page = 0
--Arrays--
fuelRods = {}
--Variables--
--Initializing Code--
mon.clear()
mon.setTextColor(colors.white)
mon.setBackgroundColor(colors.black)
--Functions--
function heading(text)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, 1)
mon.write(text)
end
function label1(text, y)
mon.setTextColor(colors.white)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, y)
mon.write(text..": ")
end
function label(text,device, y)
active = device.getActive()
mon.setTextColor(colors.white)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, y)
mon.write(text ..": ")
if active == true then
mon.setTextColor(colors.lime)
mon.write("Active")
elseif active == false then
mon.setTextColor(colors.red)
mon.write("Inactive")
end
mon.setTextColor(colors.white)
end
function casingTemp()
temp = math.floor(r.getCasingTemperature())
mon.write("Casing Temperature: ")
mon.setTextColor(colors.purple)
mon.write(temp.." C")
mon.setTextColor(colors.white)
end
function fuelReactivity()
reactivity = math.floor(r.getFuelReactivity())
mon.write("Fuel Reactivity: ")
mon.setTextColor(colors.purple)
mon.write(reactivity.."%")
mon.setTextColor(colors.white)
end
function fuelTemp()
temp =math.floor(r.getFuelTemperature())
mon.write("Fuel Temperature: ")
mon.setTextColor(colors.purple)
mon.write(temp.." C")
mon.setTextColor(colors.white)
end
function fuelConsumed()
consume = tostring(r.getFuelConsumedLastTick())
mon.write("Fuel Consumed: ")
mon.setTextColor(colors.purple)
mon.write(consume)
mon.setTextColor(colors.white)
end
function fuelAmount()
amount = math.floor(r.getFuelAmount())
mon.write("Fuel: ")
mon.setTextColor(colors.purple)
mon.write(amount.."mb")
mon.setTextColor(colors.white)
end
function wasteAmount()
waste = math.floor(r.getWasteAmount())
mon.write("Waste: ")
mon.setTextColor(colors.purple)
mon.write(waste.."mb")
mon.setTextColor(colors.white)
end
function coolantAmount()
coolant = math.floor(r.getCoolantAmount())
mon.write("Coolant: ")
mon.setTextColor(colors.purple)
mon.write(coolant.."mb")
mon.setTextColor(colors.white)
end
function hotFluidAmount()
hotFluid = math.floor(r.getHotFluidAmount())
mon.write("Hot Fluid: ")
mon.setTextColor(colors.purple)
mon.write(hotFluid.."mb")
mon.setTextColor(colors.white)
end
function controlRods()
rodCount = (tostring(reactor.getNumberOfControlRods()))
--print (rodCount)
y = 5
--rodName = (reactor.getControlRodName())
for i = 0 , rodCount-1 do
mon.setCursorPos(1,y)
mon.write(reactor.getControlRodName(i)..": "..reactor.getControlRodLevel(i).."%")
y = y+1
end
end
--************************--
function rotorSpeed()
speed = math.floor(t.getRotorSpeed())
mon.write("Rotor Speed: ")
mon.setTextColor(colors.purple)
mon.write(speed)
mon.setTextColor(colors.white)
end
function lastTickEnergy()
energy = math.floor(t.getEnergyProducedLastTick())
mon.write("Energy Produced Last Tick: ")
mon.setTextColor(colors.purple)
mon.write(energy)
mon.setTextColor(colors.white)
end
function nBlades()
blades = tostring(t.getNumberOfBlades())
mon.write("Number Of Blades: ")
mon.setTextColor(colors.purple)
mon.write(blades)
mon.setTextColor(colors.white)
end
function bladeEff()
eff = tostring(t.getBladeEfficiency())
mon.write("Blade Efficiency: ")
mon.setTextColor(colors.purple)
mon.write(eff.."%")
mon.setTextColor(colors.white)
end
function fluidFlow()
flow = t.getFluidFlowRate()
max = t.getFluidFlowRateMax()
mon.write("Flow Rate / Max: ")
mon.setTextColor(colors.purple)
mon.write(flow.."/"..max)
mon.setTextColor(colors.white)
end
--Program Code
while true do
if page == 0 then
mon.clear()
heading("Reactor - Turbine Control")
label("Reactor", r, 3)
mon.setCursorPos(1,5)
casingTemp()
mon.setCursorPos(1,6)
fuelTemp()
mon.setCursorPos(1,7)
fuelReactivity()
mon.setCursorPos(1,8)
fuelConsumed()
mon.setCursorPos(1,9)
fuelAmount()
mon.setCursorPos(1,10)
wasteAmount()
mon.setCursorPos(1,11)
coolantAmount()
mon.setCursorPos(1,12)
hotFluidAmount()
mon.setCursorPos(1,13)
mon.setBackgroundColor(colors.gray)
mon.write("Fuel Rods")
mon.setBackgroundColor(colors.black)
--********************--
label("Turbine", t, 15)
mon.setCursorPos(1,17)
rotorSpeed()
mon.setCursorPos(1,18)
lastTickEnergy()
mon.setCursorPos(1,19)
nBlades()
mon.setCursorPos(1,20)
bladeEff()
mon.setCursorPos(1,21)
fluidFlow()
elseif page == 1 then
heading("Reactor - Turbine Control")
label1("Control Rods", 3)
controlRods()
--else
--local event, param1 = os.pullEvent ("char")
--if param1 == "x" then
--break
--end
end
sleep(1)
end
local running = true
local event, param1, param2, param3
while running do
if page == 0 then
...
elseif page == 1 then
...
end
local myTimer = os.startTimer(1) -- Start a timer that will queue an event in one second. Record the timer ID in myTimer.
repeat
event, param1, param2, param3 = os.pullEvent ()
if event == "char" and param1 == "x" then
running = false
break
elseif event == "monitor_touch" then
do something else
elseif ...
etc
end
until event == "timer" and param1 == myTimer
end
local running = true local event, param1, param2, param3 while running do if page == 0 then ... elseif page == 1 then ... end local myTimer = os.startTimer(1) -- Start a timer that will queue an event in one second. Record the timer ID in myTimer. repeat event, param1, param2, param3 = os.pullEvent () if event == "char" and param1 == "x" then running = false break elseif event == "monitor_touch" then do something else elseif ... etc end until event == "timer" and param1 == myTimer end
--Peripheral Wrapping--
mon = peripheral.wrap("monitor_4")
r = peripheral.wrap("BigReactors-Reactor_0")
t = peripheral.wrap("BigReactors-Turbine_0")
page = 0
--Arrays--
fuelRods = {}
--Variables--
local running = true
local event, param1, param2, param3
--Initializing Code--
mon.clear()
mon.setTextColor(colors.white)
mon.setBackgroundColor(colors.black)
--Functions--
function heading(text)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, 1)
mon.write(text)
end
function label1(text, y)
mon.setTextColor(colors.white)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, y)
mon.write(text..": ")
end
function label(text,device, y)
active = device.getActive()
mon.setTextColor(colors.white)
w, h = mon.getSize()
mon.setCursorPos((w-string.len(text))/2+1, y)
mon.write(text ..": ")
if active == true then
mon.setTextColor(colors.lime)
mon.write("Active")
elseif active == false then
mon.setTextColor(colors.red)
mon.write("Inactive")
end
mon.setTextColor(colors.white)
end
function casingTemp()
temp = math.floor(r.getCasingTemperature())
mon.write("Casing Temperature: ")
mon.setTextColor(colors.purple)
mon.write(temp.." C")
mon.setTextColor(colors.white)
end
function fuelReactivity()
reactivity = math.floor(r.getFuelReactivity())
mon.write("Fuel Reactivity: ")
mon.setTextColor(colors.purple)
mon.write(reactivity.."%")
mon.setTextColor(colors.white)
end
function fuelTemp()
temp =math.floor(r.getFuelTemperature())
mon.write("Fuel Temperature: ")
mon.setTextColor(colors.purple)
mon.write(temp.." C")
mon.setTextColor(colors.white)
end
function fuelConsumed()
consume = tostring(r.getFuelConsumedLastTick())
mon.write("Fuel Consumed: ")
mon.setTextColor(colors.purple)
mon.write(consume)
mon.setTextColor(colors.white)
end
function fuelAmount()
amount = math.floor(r.getFuelAmount())
mon.write("Fuel: ")
mon.setTextColor(colors.purple)
mon.write(amount.."mb")
mon.setTextColor(colors.white)
end
function wasteAmount()
waste = math.floor(r.getWasteAmount())
mon.write("Waste: ")
mon.setTextColor(colors.purple)
mon.write(waste.."mb")
mon.setTextColor(colors.white)
end
function coolantAmount()
coolant = math.floor(r.getCoolantAmount())
mon.write("Coolant: ")
mon.setTextColor(colors.purple)
mon.write(coolant.."mb")
mon.setTextColor(colors.white)
end
function hotFluidAmount()
hotFluid = math.floor(r.getHotFluidAmount())
mon.write("Hot Fluid: ")
mon.setTextColor(colors.purple)
mon.write(hotFluid.."mb")
mon.setTextColor(colors.white)
end
function controlRods()
rodCount = (tostring(reactor.getNumberOfControlRods()))
--print (rodCount)
y = 5
--rodName = (reactor.getControlRodName())
for i = 0 , rodCount-1 do
mon.setCursorPos(1,y)
mon.write(reactor.getControlRodName(i)..": "..reactor.getControlRodLevel(i).."%")
y = y+1
end
end
--************************--
function rotorSpeed()
speed = math.floor(t.getRotorSpeed())
mon.write("Rotor Speed: ")
mon.setTextColor(colors.purple)
mon.write(speed)
mon.setTextColor(colors.white)
end
function lastTickEnergy()
energy = math.floor(t.getEnergyProducedLastTick())
mon.write("Energy Produced Last Tick: ")
mon.setTextColor(colors.purple)
mon.write(energy)
mon.setTextColor(colors.white)
end
function nBlades()
blades = tostring(t.getNumberOfBlades())
mon.write("Number Of Blades: ")
mon.setTextColor(colors.purple)
mon.write(blades)
mon.setTextColor(colors.white)
end
function bladeEff()
eff = tostring(t.getBladeEfficiency())
mon.write("Blade Efficiency: ")
mon.setTextColor(colors.purple)
mon.write(eff.."%")
mon.setTextColor(colors.white)
end
function fluidFlow()
flow = t.getFluidFlowRate()
max = t.getFluidFlowRateMax()
mon.write("Flow Rate / Max: ")
mon.setTextColor(colors.purple)
mon.write(flow.."/"..max)
mon.setTextColor(colors.white)
end
--Program Code
while running do
if page == 0 then
mon.clear()
heading("Reactor - Turbine Control")
label("Reactor", r, 3)
mon.setCursorPos(1,5)
casingTemp()
mon.setCursorPos(1,6)
fuelTemp()
mon.setCursorPos(1,7)
fuelReactivity()
mon.setCursorPos(1,8)
fuelConsumed()
mon.setCursorPos(1,9)
fuelAmount()
mon.setCursorPos(1,10)
wasteAmount()
mon.setCursorPos(1,11)
coolantAmount()
mon.setCursorPos(1,12)
hotFluidAmount()
mon.setCursorPos(1,13)
mon.setBackgroundColor(colors.gray)
mon.write("Fuel Rods")
mon.setBackgroundColor(colors.black)
--********************--
label("Turbine", t, 15)
mon.setCursorPos(1,17)
rotorSpeed()
mon.setCursorPos(1,18)
lastTickEnergy()
mon.setCursorPos(1,19)
nBlades()
mon.setCursorPos(1,20)
bladeEff()
mon.setCursorPos(1,21)
fluidFlow()
elseif page == 1 then
heading("Reactor - Turbine Control")
label1("Control Rods", 3)
controlRods()
local myTimer = os.startTimer(1)
repeat
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then
running = false
break
end
until event == "timer" and param1 == myTimer
end
sleep(1)
end
local myTimer = os.startTimer(1)
repeat
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then
running = false
break
end
until event == "timer" and param1 == myTimer
elseif page == 1 then
heading("Reactor - Turbine Control")
label1("Control Rods", 3)
controlRods()
local myTimer = os.startTimer(1)
repeat
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then
running = false
break
end
until event == "timer" and param1 == myTimer
end
sleep(1)
end
elseif page == 1 then
heading("Reactor - Turbine Control")
label1("Control Rods", 3)
controlRods()
end
local myTimer = os.startTimer(1)
repeat
event, param1, param2, param3 = os.pullEvent()
if event == "char" and param1 == "x" then
running = false
break
end
until event == "timer" and param1 == myTimer
end