Posted 26 August 2012 - 04:03 AM
I've been working my way into making a turtle butler inspired by a youtube video that I don't have information about at the moment…
Anyway, I have been working on implementing my first menu system for it to answer the door, asking for a password to be allowed into the house. When I try to run the startup program, though, it comes up with all sorts of errors… the first few I was able to fix, until it got to a missing equals sign… which was missing, but didn't fix the error when I changed it from if x = y to if x == y.
I solved that one, though, by copying and pasting the code from the tutorial that I was following word for word. I don't really know how the error came to be… and after that was a success, it came to another if-statement error. There is a then in plain sight, but it says "then expected". Could someone please look over this code and tell me how to make it a little more… error efficient?
Anyway, I have been working on implementing my first menu system for it to answer the door, asking for a password to be allowed into the house. When I try to run the startup program, though, it comes up with all sorts of errors… the first few I was able to fix, until it got to a missing equals sign… which was missing, but didn't fix the error when I changed it from if x = y to if x == y.
I solved that one, though, by copying and pasting the code from the tutorial that I was following word for word. I don't really know how the error came to be… and after that was a success, it came to another if-statement error. There is a then in plain sight, but it says "then expected". Could someone please look over this code and tell me how to make it a little more… error efficient?
pass = "Never accept the end."
function yN() --Start Tutorial
local n=1
while true do
local x, y=term.getCursorPos()
term.clearLine()
if n==1 then write(">YES< NO") else write (" YES >NO<") end
term.setCursorPos(x, y)
a, b=os.pullEvent()
while a~="key" do a, b=os.pullEvent() end
if b==203 and n==2 then n=1 end
if b==205 and n==1 then n=2 end
if b==28 then print("") break end
end
if n==1 then return true end
if n==2 then return false end
end --end tutorial
print ("Doorbell")
print ("Has the master ordered you here?")
answer = yN()
if answer = true then --the then in question. Is it not there?
term.clear(),
term.setCursorPos(1, 1)
print ("Doorbell")
Write ("Then what did he say? >")
secret = read ()
if secret = pass then
term.clear()
print ("Come on in!")
sleep(2)
--command butler bot
else
term.clear()
term.setCursorPos(1, 1)
print ("I'm sorry, but that is incorrect. You'll have to speak with the master.")
sleep(3)
os.shutdown()
end
else
term.clear()
term.setCursorPos(1, 1)
print ("I'm sorry, but you'll have to speak with the master for access to the house."
sleep(3)
os.shutdown()
end