Posted 27 August 2012 - 07:27 AM
I'm having some problems with my re written refinery program. Once I get through the initial password whenever I press any key, it automatically displaces the "else" piece of code, and returns to the main menu, as designed, but it even does this when I do press the right key. Also, my second loop-breaking password doesn't work. Please help, this problem has me stumped :D/>/> Thanks :P/>/>
local clients = 31
local pass = "4808"
local breakpass = "Xieylu"
local modemside = "top"
local cableside = "left"
local oil = {}
oil[1] = "On "
local fuel = {}
fuel[1] = "On "
local refinery = {}
refinery[1] = "On "
local function screenWipe()
term.clear()
term.setCursorPos(1, 1)
end
--Thirty Spaces! 9
while true do
screenWipe()
term.setCursorPos(1, 1)
print("********************************")
print("* Referiny Controller *")
print("* 1.Oil Pumps: "..oil[1].." *")
print("* 2.Fuel Pumps: "..fuel[1].." *")
print("* 3.Refinery & Pump: "..refinery[1].." *")
print("* *")
print("* Please Enter Password: *")
print("* *")
print("* *")
print("* By Nlioc4 *")
print("********************************")
term.setCursorPos(5, 8)
input = read("*")
if input == pass then
term.setCursorPos(1, 7)
term.clearLine()
write("*Press number to change status *")
term.setCursorPos(1, 8)
term.clearLine()
write("*Press Backspace to exit *")
event, param1, param2 = os.pullEvent()
if event == "char" and param1 == "1" then
if oil[1] == "On " then
table.remove(oil)
table.insert(oil,"Off")
term.setCursorPos(1, 9)
term.clearLine()
write("* Shutting Down Oil Pumps *")
sleep(1)
term.setcursorPos(1, 9)
term.clearLine()
print("* *")
elseif oil[1] == "Off" then
table.remove(oil)
table.insert(oil,"On ")
term.setCursorPos(1, 9)
term.clearLine()
write("* Enabling Oil Pumps *")
sleep(1)
term.setCursorPos(1, 9)
term.clearLine()
print("* *")
end
elseif event == "char" and param1 == "2" then
if fuel[1] == "On " then
table.remove(fuel)
table.insert(fuel,"Off")
term.setCursorPos(1, 9)
term.clearLine()
write("* Shutting Down Fuel Pumps *")
sleep(1)
term.setCursorPos()
term.clearLine()
elseif fuel[1] == "Off" then
table.remove(fuel)
table.insert(fuel,"On ")
term.setCursorPos(1, 9)
term.clearLine()
write("* Enabling Fuel Pumps *")
sleep(1)
term.setCursorPos(1, 9)
term.clearLine()
print("* *")
end
elseif event == "char" and param1 == "3" then
if refinery[1] == "On " then
table.remove(refinery)
table.insert(refinery,"Off")
term.setCursorPos(1, 9)
term.clearLine()
write("* Shutting Down Refinery *")
sleep(1)
term.setCursorPos(1, 9)
term.clearLine()
print("* *")
elseif refinery[1] == "Off" then
table.remove(refinery)
table.insert(refinery,"On ")
term.setCursorPos(1, 9)
term.clearLine()
write("* Enabling Refinery *")
sleep(1)
term.setCursorPos(1, 9)
term.clearLine()
print("* *")
end
elseif event == "key" and param1 == "14" then
return
else
term.setCursorPos(1, 9)
term.clearLine()
write("* Unrecognized Keypress *")
sleep(3)
term.setCursorPos(1, 9)
term.clearLine()
end
elseif pass == breakpass then
break
else
term.setCursorPos(1, 9)
term.clearLine()
write("* Unrecognized Password *")
sleep(3)
term.setCursorPos(1, 9)
term.clearLine()
end
end