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

Code issues

Started by predatorxil, 23 August 2012 - 10:49 PM
predatorxil #1
Posted 24 August 2012 - 12:49 AM
I have been working on a terminal program so i can login to thecomputer, or use for passwords, either way, im getting a problem.
First- There is no error being shown
second- Entering the Correct "username" and "password" lets you in,
thrid- if you enter random text into the username field, it seems to just quit, and lets players use the terminal with full access!
Please help anyway! Thanks!


local sPath = ":/rom/programs"
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Welcome to R.S. Incorporated")
term.setCursorPos(1,2)
print("----------------------------------------------------------")
term.setCursorPos(1,3)
print("Terminal Version 2.1")
term.setCursorPos(1,4)
print("Users: ")
term.setCursorPos(1,5)
textutils.slowPrint("- predatorxil  - nexoigi")
term.setCursorPos(1,6)
textutils.slowPrint("- axel1298	 - ztrevetty88")
term.setCursorPos(1,7)
textutils.slowPrint("- coolwater97")
term.setCursorPos(1,8)
print("----------------------------------------------------------")
term.setCursorPos(1,9)
textutils.slowPrint("Message: ")
term.setCursorPos(1,10)
os.pullEvent
maxuser = "admin"
maxpassword = "13034"
write("Username: ")
input = read()
if input == maxuser then
term.setCursorPos(1,11)
write("Password: ")
input = read("*")
if input == maxpassword then
  term.setCursorPos(10,9)
  textutils.slowPrint("Access Approved")
  sleep(2)
  term.clear()
  term.setCursorPos(1,1)
  textutils.slowPrint("R.S. Incorporated Terminal")
  term.setCursorPos(1,2)
  print("----------------------------------------------------------")
  term.setCursorPos(1,3)
  textutils.slowPrint("Administrator: Full Access")
  term.setCursorPos(1,4)
else
term.setCursorPos(10,9)
textutils.slowPrint("Access Denied")
sleep(2)
os.reboot()
	end
end
Graypup #2
Posted 24 August 2012 - 01:34 AM
Make it os.shutdown() every time the login fails. That is a normal function of the shell when a program crashes, to send you back to the shell prompt.
Graypup #3
Posted 26 August 2012 - 09:35 PM
*blah, blah, blah*

local sPath = ":/rom/programs"
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Welcome to R.S. Incorporated")
term.setCursorPos(1,2)
print("----------------------------------------------------------")
term.setCursorPos(1,3)
print("Terminal Version 2.1")
term.setCursorPos(1,4)
print("Users: ")
term.setCursorPos(1,5)
textutils.slowPrint("- predatorxil  - nexoigi")
term.setCursorPos(1,6)
textutils.slowPrint("- axel1298	 - ztrevetty88")
term.setCursorPos(1,7)
textutils.slowPrint("- coolwater97")
term.setCursorPos(1,8)
print("----------------------------------------------------------")
term.setCursorPos(1,9)
textutils.slowPrint("Message: ")
term.setCursorPos(1,10)
os.pullEvent
maxuser = "admin"
maxpassword = "13034"
write("Username: ")
input = read()
if input == maxuser then
term.setCursorPos(1,11)
write("Password: ")
input = read("*")
if input == maxpassword then
  term.setCursorPos(10,9)
  textutils.slowPrint("Access Approved")
  sleep(2)
  term.clear()
  term.setCursorPos(1,1)
  textutils.slowPrint("R.S. Incorporated Terminal")
  term.setCursorPos(1,2)
  print("----------------------------------------------------------")
  term.setCursorPos(1,3)
  textutils.slowPrint("Administrator: Full Access")
  term.setCursorPos(1,4)
else
term.setCursorPos(10,9)
textutils.slowPrint("Access Denied")
sleep(2)
os.reboot()
end
Fixed the code in the quote