while true do
local reactor1 = peripheral.wrap("BigReactors-Reactor_1")
local mon = peripheral.wrap("top")
mon.clear()
-- Begin Reactor 1
--mon.setCursorPos(1,1)
--mon.setTextColor(colors.white)
--mon.write("Reactor #: ")
--mon.setTextColor(colors.lime)
--mon.write("1")
mon.setCursorPos(1,1)
mon.setTextColor(colors.white)
mon.write("Active: ")
mon.setTextColor(colors.lime)
mon.write(reactor1.getActive())
mon.setCursorPos(1,2)
mon.setTextColor(colors.white)
mon.write("RF/T: ")
mon.setTextColor(colors.lime)
mon.write(math.floor(reactor1.getEnergyProducedLastTick()))
mon.setCursorPos(1,3)
mon.setTextColor(colors.white)
mon.write("Control Rods: ")
mon.setTextColor(colors.lime)
mon.write(math.floor(reactor1.getNumberOfControlRods()))
mon.setCursorPos(1,4)
mon.setTextColor(colors.white)
mon.write("RF Stored: ")
mon.setTextColor(colors.lime)
mon.write(math.floor(reactor1.getEnergyStored()))
mon.setCursorPos(1,5)
mon.setTextColor(colors.white)
mon.write("Casing Heat: ")
mon.setTextColor(colors.lime)
mon.write(math.floor(reactor1.getCasingTemperature()))
mon.setCursorPos(1,6)
mon.setTextColor(colors.white)
mon.write("Fuel Heat: ")
mon.setTextColor(colors.lime)
mon.write(math.floor(reactor1.getFuelTemperature()))
end <------------------------------------------ end goes here
-- End Reactor 1
function Clicks()
mon.setCursorPos(1,7)
print("ON")
mon.setCursorPos(1,8)
print("OFF")
end
function Pick()
while true do
event,side,x,y = os.pullEvent()
if event == "monitor_touch" then
if x == 1 and y == 7 then
reactor.setActive(true)
elseif x == 1 and y == 8 then
reactor.setActive(false)
end
end
sleep(5)
end
end
By writing code out like this you can see where the code blocks begin and end. This helps keep code organized and also helps you be able to find where there needs to be ends. As you can see you started the program with a while loop, but there is no end that closes it. Where it says "-- end Reactor 1" is where there needs to be a end to close the while loop that started at the beginning of the program. It is good practice to indent each time you start a new block. A block includes any type of loop, if statement, or a function. When reading over it ends should line up vertically with what they end. It might seem like a little more work, but it makes it easier to read and know where ends are suppose to be placed.
Edited by valithor, 18 October 2014 - 12:43 AM.