Posted 08 October 2016 - 06:18 PM
Hello there everyone. The program I am having an issue with is designed to turn on/off a large group of reactors and turbines from the Big Reactors mod in sequence. Thanks to previous posts in the forum I was able to work out all of the actual errors, but now I am having an actual bug in it.
What is supposed to happen is if you type in "startup" it runs the startup sequence, and when you type in "shutdown" it does the shutdown sequence, and everything else tells you to try again. Right now though you could faceroll your keyboard and have it run the startup sequence. It wont run the elseif or else statements later in the program no matter what input.
Any help would be appreciated, and if you have any ideas for making the program shorter that would be nice too, I realize there is a lot of repetition.
Here is a pastebin http://pastebin.com/PbXPu9k1 and under the spoiler in the same code for completeness.
[indent=1]
[/indent]
If the startup program for this computer or the other end of the rednet.send/receive and its startup are needed let me know. And thanks in advance.
What is supposed to happen is if you type in "startup" it runs the startup sequence, and when you type in "shutdown" it does the shutdown sequence, and everything else tells you to try again. Right now though you could faceroll your keyboard and have it run the startup sequence. It wont run the elseif or else statements later in the program no matter what input.
Any help would be appreciated, and if you have any ideas for making the program shorter that would be nice too, I realize there is a lot of repetition.
Here is a pastebin http://pastebin.com/PbXPu9k1 and under the spoiler in the same code for completeness.
[indent=1]
Spoiler
reactorID = 52
turbine1 = peripheral.wrap("BigReactors-Turbine_0")
turbine2 = peripheral.wrap("BigReactors-Turbine_1")
turbine3 = peripheral.wrap("BigReactors-Turbine_2")
turbine4 = peripheral.wrap("BigReactors-Turbine_3")
turbine5 = peripheral.wrap("BigReactors-Turbine_4")
turbine6 = peripheral.wrap("BigReactors-Turbine_5")
turbine7 = peripheral.wrap("BigReactors-Turbine_6")
turbine8 = peripheral.wrap("BigReactors-Turbine_7")
turbine9 = peripheral.wrap("BigReactors-Turbine_8")
turbine10 = peripheral.wrap("BigReactors-Turbine_9")
turbine11 = peripheral.wrap("BigReactors-Turbine_12")
turbine12 = peripheral.wrap("BigReactors-Turbine_13")
turbine13 = peripheral.wrap("BigReactors-Turbine_14")
turbine14 = peripheral.wrap("BigReactors-Turbine_15")
turbine15 = peripheral.wrap("BigReactors-Turbine_16")
turbine16 = peripheral.wrap("BigReactors-Turbine_17")
turbine17 = peripheral.wrap("BigReactors-Turbine_19")
turbine18 = peripheral.wrap("BigReactors-Turbine_20")
turbine19 = peripheral.wrap("BigReactors-Turbine_21")
turbine20 = peripheral.wrap("BigReactors-Turbine_22")
turbine21 = peripheral.wrap("BigReactors-Turbine_23")
turbine22 = peripheral.wrap("BigReactors-Turbine_24")
turbine23 = peripheral.wrap("BigReactors-Turbine_25")
turbine24 = peripheral.wrap("BigReactors-Turbine_26")
turbine25 = peripheral.wrap("BigReactors-Turbine_27")
while true do
write("Startup or Shutdown? ")
local response = read()
if response == "Startup" or "startup" then
rednet.send(reactorID, "startup")
local senderID, message, protocol = rednet.receive()
if senderID == reactorID and message == "OK" then
print("Starting Reactor...")
else print("Reactor already running.")
end
sleep(0.5)
if turbine1.getActive() == false then
turbine1.setActive(true)
print("Starting Turbine 1...")
else print("Turbine 1 already running.")
end
sleep(0.5)
if turbine2.getActive() == false then
turbine2.setActive(true)
print("Starting Turbine 2...")
else print("Turbine 2 already running.")
end
sleep(0.5)
if turbine3.getActive() == false then
turbine3.setActive(true)
print("Starting Turbine 3...")
else print("Turbine 3 already running.")
end
sleep(0.5)
if turbine4.getActive() == false then
turbine4.setActive(true)
print("Starting Turbine 4...")
else print("Turbine 4 already running.")
end
sleep(0.5)
if turbine5.getActive() == false then
turbine5.setActive(true)
print("Starting Turbine 5...")
else print("Turbine 5 already running.")
end
sleep(0.5)
if turbine6.getActive() == false then
turbine6.setActive(true)
print("Starting Turbine 6...")
else print("Turbine 6 already running.")
end
sleep(0.5)
if turbine7.getActive() == false then
turbine7.setActive(true)
print("Starting Turbine 7...")
else print("Turbine 7 already running.")
end
sleep(0.5)
if turbine8.getActive() == false then
turbine8.setActive(true)
print("Starting Turbine 8...")
else print("Turbine 8 already running.")
end
sleep(0.5)
if turbine9.getActive() == false then
turbine9.setActive(true)
print("Starting Turbine 9...")
else print("Turbine 9 already running.")
end
sleep(0.5)
if turbine10.getActive() == false then
turbine10.setActive(true)
print("Starting Turbine 10...")
else print("Turbine 10 already running.")
end
sleep(0.5)
if turbine11.getActive() == false then
turbine11.setActive(true)
print("Starting Turbine 11...")
else print("Turbine 11 already running.")
end
sleep(0.5)
if turbine12.getActive() == false then
turbine12.setActive(true)
print("Starting Turbine 12...")
else print("Turbine 12 already running.")
end
sleep(0.5)
if turbine13.getActive() == false then
turbine13.setActive(true)
print("Starting Turbine 13...")
else print("Turbine 13 already running.")
end
sleep(0.5)
if turbine14.getActive() == false then
turbine14.setActive(true)
print("Starting Turbine 14...")
else print("Turbine 14 already running.")
end
sleep(0.5)
if turbine15.getActive() == false then
turbine15.setActive(true)
print("Starting Turbine 15...")
else print("Turbine 15 already running.")
end
sleep(0.5)
if turbine16.getActive() == false then
turbine16.setActive(true)
print("Starting Turbine 16...")
else print("Turbine 16 already running.")
end
sleep(0.5)
if turbine17.getActive() == false then
turbine17.setActive(true)
print("Starting Turbine 17...")
else print("Turbine 17 already running.")
end
sleep(0.5)
if turbine18.getActive() == false then
turbine18.setActive(true)
print("Starting Turbine 18...")
else print("Turbine 18 already running.")
end
sleep(0.5)
if turbine19.getActive() == false then
turbine19.setActive(true)
print("Starting Turbine 19...")
else print("Turbine 19 already running.")
end
sleep(0.5)
if turbine20.getActive() == false then
turbine20.setActive(true)
print("Starting Turbine 20...")
else print("Turbine 20 already running.")
end
sleep(0.5)
if turbine21.getActive() == false then
turbine21.setActive(true)
print("Starting Turbine 21...")
else print("Turbine 21 already running.")
end
sleep(0.5)
if turbine22.getActive() == false then
turbine22.setActive(true)
print("Starting Turbine 22...")
else print("Turbine 22 already running.")
end
sleep(0.5)
if turbine23.getActive() == false then
turbine23.setActive(true)
print("Starting Turbine 23...")
else print("Turbine 23 already running.")
end
sleep(0.5)
if turbine24.getActive() == false then
turbine24.setActive(true)
print("Starting Turbine 24...")
else print("Turbine 24 already running.")
end
sleep(0.5)
if turbine25.getActive() == false then
turbine25.setActive(true)
print("Starting Turbine 25...")
else print("Turbine 25 already running.")
end
sleep(0.5)
print("Startup complete.")
elseif response == "Shutdown" or "shutdown" then
rednet.send(reactorID, "shutdown")
local senderID, message, protocol = rednet.receive()
if senderID == reactorID and message == "OK" then
print("Stopping Reactor...")
else print("Reactor already offline.")
end
sleep(0.5)
if turbine1.getActive() == true then
turbine1.setActive(false)
print("Stopping Turbine 1...")
else print("Turbine 1 already offline.")
end
sleep(0.5)
if turbine2.getActive() == true then
turbine2.setActive(false)
print("Stopping Turbine 2...")
else print("Turbine 2 already offline.")
end
sleep(0.5)
if turbine3.getActive() == true then
turbine3.setActive(false)
print("Stopping Turbine 3...")
else print("Turbine 3 already offline.")
end
sleep(0.5)
if turbine4.getActive() == true then
turbine4.setActive(false)
print("Stopping Turbine 4...")
else print("Turbine 4 already offline.")
end
sleep(0.5)
if turbine5.getActive() == true then
turbine5.setActive(false)
print("Stopping Turbine 5...")
else print("Turbine 5 already offline.")
end
sleep(0.5)
if turbine6.getActive() == true then
turbine6.setActive(false)
print("Stopping Turbine 6...")
else print("Turbine 6 already offline.")
end
sleep(0.5)
if turbine7.getActive() == true then
turbine7.setActive(false)
print("Stopping Turbine 7...")
else print("Turbine 7 already offline.")
end
sleep(0.5)
if turbine8.getActive() == true then
turbine8.setActive(false)
print("Stopping Turbine 8...")
else print("Turbine 8 already offline.")
end
sleep(0.5)
if turbine9.getActive() == true then
turbine9.setActive(false)
print("Stopping Turbine 9...")
else print("Turbine 9 already offline.")
end
sleep(0.5)
if turbine10.getActive() == true then
turbine10.setActive(false)
print("Stopping Turbine 10...")
else print("Turbine 10 already offline.")
end
sleep(0.5)
if turbine11.getActive() == true then
turbine11.setActive(false)
print("Stopping Turbine 11...")
else print("Turbine 11 already offline.")
end
sleep(0.5)
if turbine12.getActive() == true then
turbine12.setActive(false)
print("Stopping Turbine 12...")
else print("Turbine 12 already offline.")
end
sleep(0.5)
if turbine13.getActive() == true then
turbine13.setActive(false)
print("Stopping Turbine 13...")
else print("Turbine 13 already offline.")
end
sleep(0.5)
if turbine14.getActive() == true then
turbine14.setActive(false)
print("Stopping Turbine 14...")
else print("Turbine 14 already offline.")
end
sleep(0.5)
if turbine15.getActive() == true then
turbine15.setActive(false)
print("Stopping Turbine 15...")
else print("Turbine 15 already offline.")
end
sleep(0.5)
if turbine16.getActive() == true then
turbine16.setActive(false)
print("Stopping Turbine 16...")
else print("Turbine 16 already offline.")
end
sleep(0.5)
if turbine17.getActive() == true then
turbine17.setActive(false)
print("Stopping Turbine 17...")
else print("Turbine 17 already offline.")
end
sleep(0.5)
if turbine18.getActive() == true then
turbine18.setActive(false)
print("Stopping Turbine 18...")
else print("Turbine 18 already offline.")
end
sleep(0.5)
if turbine19.getActive() == true then
turbine19.setActive(false)
print("Stopping Turbine 19...")
else print("Turbine 19 already offline.")
end
sleep(0.5)
if turbine20.getActive() == true then
turbine20.setActive(false)
print("Stopping Turbine 20...")
else print("Turbine 20 already offline.")
end
sleep(0.5)
if turbine21.getActive() == true then
turbine21.setActive(false)
print("Stopping Turbine 21...")
else print("Turbine 21 already offline.")
end
sleep(0.5)
if turbine22.getActive() == true then
turbine22.setActive(false)
print("Stopping Turbine 22...")
else print("Turbine 22 already offline.")
end
sleep(0.5)
if turbine23.getActive() == true then
turbine23.setActive(false)
print("Stopping Turbine 23...")
else print("Turbine 23 already offline.")
end
sleep(0.5)
if turbine24.getActive() == true then
turbine24.setActive(false)
print("Stopping Turbine 24...")
else print("Turbine 24 already offline.")
end
sleep(0.5)
if turbine25.getActive() == true then
turbine25.setActive(false)
print("Stopping Turbine 25...")
else print("Turbine 25 already offline.")
end
sleep(0.5)
print("Shutdown complete.")
else print("Please try again.")
end
end
If the startup program for this computer or the other end of the rednet.send/receive and its startup are needed let me know. And thanks in advance.