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

I Need Help For My Login Program

Started by Saxguy99, 27 August 2013 - 09:33 AM
Saxguy99 #1
Posted 27 August 2013 - 11:33 AM
Hi i was wandering i anyone can help me with this error. Ok so i keep getting this error bios:338: [string "login]:34: 'end' expected (to close 'while' at line 2. That's the exact error. Here is the code. Also when the type in the wrong user name it or wrong pass word it lets them im any ways. The fist set of code is the Login program and the 2 set of code is the server program that the login program runs from. They send rednet messages to verify the username and Password but its letting them through no matter wat can anyone help plzz.

1. Login Program 34 Lines

rednet.open("right")
while true do
  term.setBackgroundColor(colors.blue)
  term.clear()
  term.setCursorPos(16,8)
  write("Username: ")
  Uname = read()
  rednet.send(12, Uname)
  senderId,message,distance = rednet.receive()
	if message == "UserValid" then
	  term.setCursorPos(16,10)
	  write("Password: ")
	  Pword = read("*")
	  rednet.send(12, Pword)
	  senderId,message,distance = rednet.receive()
	  if message == "PassValid" then
		term.setCursorPos(16,12)
		print("Vaild Login")
		sleep(2)
		shell.run("SOS")
  os.shutdown()
	  elseif message == "PassInvalid" then
	 if message == "PassValid" then
		term.setCursorPos(16,12)
		print("Invalid Login")
		sleep(2)
		os.reboot()
   end
elseif message == "UserInvalid" then
		term.setCursorPos(16,12)
		print("Invalid Username(Case sensitive)")
		sleep(2)
  os.reboot()  
end
end

2. Server Program 31 Lines

term.clear()
term.setCursorPos(1,1)
rednet.open("right")
m = peripheral.wrap("left")
usernames = {"Saxguy99"}
computers = {9}
passwords = {"1234"}
term.setBackgroundColor(colors.orange)
term.setTextColor(colors.black)
print("This is a server go login to another terminal")
while true do
time = textutils.formatTime(os.time(), false)
senderId,message,distance = rednet.receive()
print("received")
if message == usernames[1] then
  sleep(1)
  rednet.send(senderId, "UserValid")
  senderId,message,distance = rednet.receive()
  if message == passwords[1] then
   sleep(1)
   rednet.send(senderId, "PassValid")
  else
   sleep(1)
   rednet.send(senderId, "PassInvalid")
  end
else
  sleep(1)
  rednet.send(senderId, "UserInvalid")
end
end
Last1Here #2
Posted 27 August 2013 - 12:32 PM
you missed an end

rednet.open("right")
while true do
	term.setBackgroundColor(colors.blue)
	term.clear()
	term.setCursorPos(16,8)
	write("Username: ")
	Uname = read()
	rednet.send(12, Uname)
	senderId,message,distance = rednet.receive()
    if message == "UserValid" then
		term.setCursorPos(16,10)
		write("Password: ")
		Pword = read("*")
		rednet.send(12, Pword)
		senderId,message,distance = rednet.receive()
		if message == "PassValid" then
            term.setCursorPos(16,12)
            print("Vaild Login")
            sleep(2)
            shell.run("SOS")
			os.shutdown()
        elseif message == "PassInvalid" then
			if message == "PassValid" then -- i dont even know what this is for
				term.setCursorPos(16,12)
				print("Invalid Login")
				sleep(2)
				os.reboot()
			end --here
		end
	elseif message == "UserInvalid" then
        term.setCursorPos(16,12)
        print("Invalid Username(Case sensitive)")
        sleep(2)
		os.reboot()  
	end
end
Saxguy99 #3
Posted 27 August 2013 - 12:53 PM
Thanks it works BTW you have helped me 2 time to day thanks for everything Last1Here