This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Decater's profile picture

Little PW-Door

Started by Decater, 21 April 2014 - 09:29 PM
Decater #1
Posted 21 April 2014 - 11:29 PM
Hey im a newb in lua and i just saw some tuts and now i wrote a program for my door but always i recieve the msg
bios:338; [string "startup"]:9: ')' expected

here is my work

os.pullEvent = os.pullEventRaw
shell.run("clear")
function password()
print("Please enter the Password\n\n")
write("Password :")
PW =io.read()
if PW =="Liss" then
  shell.run("clear")
  rs.setOutput("back". true)
  sleep(6)
  rs.setOutput("back". false)
  shell.run("clear")
  password()
else
  shell.run("clear")
  shell.run("reboot")
  password()
  end
end
password()

Hope i find some help ^^
Lyqyd #2
Posted 22 April 2014 - 01:40 AM
Moved to Ask a Pro.
Xixili #3
Posted 22 April 2014 - 01:42 AM

os.pullEvent = os.pullEventRaw
shell.run("clear")
function password()
print("Please enter the Password\n\n")
write("Password :")
PW =io.read()
if PW =="Liss" then
  shell.run("clear")
  rs.setOutput("back", true)
  sleep(6)
  rs.setOutput("back", false)
  shell.run("clear")
  password()
else
  shell.run("clear")
  shell.run("reboot")
  password()
  end
end
password()

Fixed.

You used a . instead of ,


I use this one, it has a simple GUI:


os.pullEvent = os.pullEventRaw
local standby = 5
local side = "back"
local password = "changeme"

local width, height = term.getSize()

-- == GUI Settings

term.setCursorPos(1, 1)
term.setBackgroundColor(colors.white)
term.clear()

term.setTextColor(colors.white)
term.setBackgroundColor(colors.orange)
term.clearLine()

term.setCursorPos(1, height)
term.clearLine()

local text = "Xixili Security Door"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)

-- == Passlock

term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
term.setCursorPos(3, 3)
term.write("Password: ")
local input = read("*")

term.setCursorPos(3, 5)
if input == password then
	term.write("Correct")
	rs.setOutput(side, true)
	sleep(5)
	rs.setOutput(side, false)
else
	term.write("Wrong Password")
	sleep(2)
end
os.reboot()
Edited on 21 April 2014 - 11:46 PM
Decater #4
Posted 22 April 2014 - 01:59 AM
Thx *-* i`ll try to understand your way but i think i learn more when i just start slowly with my prgram. Thx you are nice :)/>