Posted 15 December 2012 - 11:03 AM
I am pretty new to Lua, almost everything I know is from learning in the past week. Right now I have a system that basically manages 3 outputs. It's probably pretty basic for a lot of you. but I am having 2 problems, and one thing that I can't seem to be able to find on the internet. I'll put the 2 problems I'm having if you want to try and figure out what's going on, but I will keep this post about the other thing. I'll put the problems in orange in the code.
Basically what happens is whenever something fills up, it lets off a redstone signal. I want that signal to lead into the computer and then display that it's full and not allow you to type in certain commands. But the only way that I know to get a redstone input is on a loop and restricts users from typing anything or interacting with the computer.
this is the main code. It's called "visproduction"
and here is the "editpass" program code.
This is my first forum post so I hope it's formatted correctly and not too much. Thanks for your help in advance.
Basically what happens is whenever something fills up, it lets off a redstone signal. I want that signal to lead into the computer and then display that it's full and not allow you to type in certain commands. But the only way that I know to get a redstone input is on a loop and restricts users from typing anything or interacting with the computer.
this is the main code. It's called "visproduction"
term.write("What would you like to do?")
print ("")
local input = read()
if input == "help" then
term.clear()
term.setCursorPos(1, 1)
print ("Options are as follows:")
print ("")
print ("'Start' or 'Start vis production'")
print ("'Stop' or 'Stop vis production'")
print ("'Boost' or 'Boost vis production'")
print ("'Clear'")
print ("'estop'")
print ("'exit'")
print ("'shut down'")
– print ("'check vis production status'") –this is how I want to check to see how it's running.
sleep(1)
shell.run("visproduction")
end
if input == "start" then
rs.setBundledOutput("back",1)
sleep(1)
shell.run("visproduction")
end
if input == "Start" then
rs.setBundledOutput("back",1)
sleep(1)
shell.run("visproduction")
end
if input == "start vis production" then
rs.setBundledOutput("back",1)
sleep(1)
shell.run("visproduction")
end
if input == "Start vis production" then
rs.setBundledOutput("back",1)
sleep(1)
shell.run("visproduction")
end
if input == "stop" then
rs.setBundledOutput("back",0)
sleep(1)
shell.run("visproduction")
end
if input == "Stop" then
rs.setBundledOutput("back",0)
sleep(1)
shell.run("visproduction")
end
if input == "stop vis production" then
rs.setBundledOutput("back",0)
sleep(1)
shell.run("visproduction")
end
if input == "Stop vis production" then
rs.setBundledOutput("back",0)
sleep(1)
shell.run("visproduction")
end
if input == "boost" then
rs.setBundledOutput("back",3)
sleep(1)
rs.setBundledOutput("back",1)
shell.run("visproduction")
end
if input == "Boost" then
rs.setBundledOutput("back",3)
sleep(1)
rs.setBundledOutput("back",1)
shell.run("visproduction")
end
if input == "boost vis production" then
rs.setBundledOutput("back",3)
sleep(1)
rs.setBundledOutput("back",1)
shell.run("visproduction")
end
if input == "Boost vis production" then
rs.setBundledOutput("back",3)
sleep(1)
rs.setBundledOutput("back",1)
shell.run("visproduction")
end
if input == "estop" then
rs.setBundledOutput("back",4)
shell.run("visproduction")
end
if input == "Estop" then
rs.setBundledOutput("back",4)
shell.run("visproduction")
end
if input == "clear" then
term.clear()
term.setCursorPos(1, 1)
shell.run("visproduction")
end
if input == "edit" then
print("Only authorized users can edit this program. Password Required")
sleep(2)
shell.run("editpass")
end
–this part comes back as the else code, and doesn't do shell.exit()
if input == "exit" then
shell.exit()
end
–
if input == "shut down" then
print("Shutting down Production OS. Please wait as it saves and safely shuts down the system.")
sleep(3)
print("Saving settings")
sleep(1)
print("Shutting down secondary processes")
sleep(0.5)
print("Shutting Down")
sleep(4)
os.shutdown()
else
print("not a valid operation")
shell.run("visproduction")
end
and here is the "editpass" program code.
correctpass = "Secret1"
write("Insert password here: ")
pass = read()
if pass == (correctpass) then
print("Correct, You may now edit this program.")
sleep(1)
print("saving content to prevent data loss")
sleep(1)
print("Shutting down secondary processes")
sleep(0.5)
print("Restarting. You will be in the editing screen upon startup")
sleep(4)shell.run("edit","visproduction") –when I'm in the edit screen, then exit with ctrl E, it's like it runs visproduction, and then I –typed "e" as a code, so it returns as another else.
else
print("Incorrect")
sleep(1)
shell.run("visproduction")
end
This is my first forum post so I hope it's formatted correctly and not too much. Thanks for your help in advance.