Posted 11 March 2012 - 09:53 PM
Hey you guys!
I'm pretty new to Computercraft and coding and general and trying to write a program to run my refinery. I'm trying to read if the computer set an output for a specific cable to tell me in the control screen if the regarding machine is turned on (gets a signal from the computer) or not.
First I'll post the code I had till now.
Now I'm trying to toggle this label "OFF". Instead of reading the Output and printing the regarding message it just sets the output..
I hope you can help me :mellow:/>/>
I'm pretty new to Computercraft and coding and general and trying to write a program to run my refinery. I'm trying to read if the computer set an output for a specific cable to tell me in the control screen if the regarding machine is turned on (gets a signal from the computer) or not.
First I'll post the code I had till now.
shell.run("clear")
print("----------------------------------")
sleep(0.1)
print("| Controls |")
sleep(0.1)
print("| 1. Oilpumps and refinery - OFF |")
sleep(0.1)
print("| 2. Engines - fuel - OFF |")
sleep(0.1)
print("| 3. Engines - water - OFF |")
sleep(0.1)
print("| 4. Engines start - OFF |")
sleep(0.1)
print("| 5. Waterpumps - OFF |")
sleep(0.1)
print("| 6. Exit |")
sleep(0.1)
print("----------------------------------")
input = read()
if input == "1" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.white)
print("Oil pumps and refinery engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "2" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.black)
print("Engine fuel engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "3" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.yellow)
rs.setBundledOutput("back", colors.yellow)
print("Engine water engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "4" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.red)
print("Engines engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "5" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.orange)
rs.setBundledOutput("back", colors.orange)
print("Waterpumps engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "6" then
shell.run("exit")
elseif input == other then
print("Please type the number")
sleep(2.0)
shell.run("refinerycontrol.txt")
else print("not available")
shell.run("rom/programs/custom/refinerycontrol.txt")
end
Now I'm trying to toggle this label "OFF". Instead of reading the Output and printing the regarding message it just sets the output..
shell.run("clear")
print("----------------------------------")
sleep(0.1)
print("| Controls |")
sleep(0.1)
if rs.setBundledOutput("bottom", colors.white) == TRUE then
print("| 1. Oilpumps and refinery - ON |")
else
print("| 1. Oilpumps and refinery - OFF |")
end
sleep(0.1)
print("| 2. Engines - fuel - OFF |")
sleep(0.1)
print("| 3. Engines - water - OFF |")
sleep(0.1)
print("| 4. Engines start - OFF |")
sleep(0.1)
print("| 5. Waterpumps - OFF |")
sleep(0.1)
print("| 6. Exit |")
sleep(0.1)
print("----------------------------------")
input = read()
if input == "1" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.white)
print("Oil pumps and refinery engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "2" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.black)
print("Engine fuel engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "3" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.yellow)
rs.setBundledOutput("back", colors.yellow)
print("Engine water engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "4" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.red)
print("Engines engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "5" then
print("Engaging")
sleep(1.0)
rs.setBundledOutput("bottom", colors.orange)
rs.setBundledOutput("back", colors.orange)
print("Waterpumps engaged")
sleep(2.0)
shell.run("rom/programs/custom/refinerycontrol.txt")
elseif input == "6" then
shell.run("exit")
elseif input == other then
print("Please type the number")
sleep(2.0)
shell.run("refinerycontrol.txt")
else print("not available")
shell.run("rom/programs/custom/refinerycontrol.txt")
end
I hope you can help me :mellow:/>/>