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

[Programming] [menu] HELP 2

Started by Goof, 22 September 2012 - 01:40 PM
Goof #1
Posted 22 September 2012 - 03:40 PM
Hey! ehm


i cannot solve this "repeat" problem…when i entered the "Username", and was wrong, then it dosen't repeat "ENTER USERNAME" ehm… why?
also when the Username is Correct, then it dosen't continue to the "Enter Password"….

in the terminal it dosent show the "Enter Username" then it did go directly to the Password function….. Why????
can someone help me???




+———————-+
+ Enter Username +
+———————-+
+———————-+
+ Enter Password +
+———————-+

Spoiler



sid = 0

function startup()



function Clear(arg1,arg2)
term.clear()
term.setCursorPos(arg1,arg2)
end

Clear(1,1)


door1 = 0
door2 = 0
door3 = 0
door4 = 0
door5 = 0
door6 = 0
door7 = 0
door8 = 0
door9 = 0
door10 = 0
door11 = 0
door12 = 0

close1 = "!"
open1 = "-"

function checkDoors()

if door1 == 0 then
check1 = "-"
else
check1 = "!"
end

if door2 == 0 then
check2 = "-"
else
check2 = "!"
end

if door3 == 0 then
  check3 = "-"
else
  check3 = "!"
end

if door4 == 0 then
  check4 = "-"
else
  check4 = "!"
end

if door5 == 0 then
check5 = "-"
else
check5 = "!"
end

if door6 == 0 then
check6 = "-"
else
check6 = "!"
end

if door7 == 0 then
  check7 = "-"
else
  check7 = "!"
end

if door8 == 0 then
  check8 = "-"
else
  check8 = "!"
end

if door9 == 0 then
check9 = "-"
else
check9 = "!"
end

if door10 == 0 then
check10 = "-"
else
check10 = "!"
end

if door11 == 0 then
  check11 = "-"
else
  check11 = "!"
end

if door12 == 0 then
  check12 = "-"
else
  check12 = "!"
end
end

checkDoors()





print(" +---+---+---+---+---+---+---+---+---+---+---+--+")
print(" + 1 ! 2 ! 3 ! 4 ! 5 ! 6 ! 7 ! 8 ! 9 !10 !11 !12+")
print(" +-"..check1.."-+-"..check2.."-+-"..check3.."-+-"..check4.."-+-"..check5.."-+-"..check6.."-+-"..check7.."-+-"..check8.."-+-"..check9.."-+-"..check10.."-+-"..check11.."-+-"..check12.."+")
print("")
print("")
print(" +----------------------------------------------+")
print(" + Log-In to edit Jail Options! : Login  / Exit +")
print(" +----------------------------------------------+")			  




end





while true do

term.setCursorPos(1,4)
print("+-------------------------+")
print("+ Enter Password!		 +")
print("+-------------------------+")
term.setCursorPos(3,2)

password = read("#")
if password == "ShutUp" then
   print("Acces Granted")
   sleep(4)
   startup()

   return false

else
   print("Acces Denied!")
sleep(2)
return true
end
end


--[[#########################################]]--								This mark is here the Error is...


function Logg1()
while true do																  

term.clear()
term.setCursorPos(1,1)

print("+-------------------------+")
print("+ Enter Username		  +")
print("+-------------------------+")
term.setCursorPos(3,2)
username = read()
if username == "Admin1" then
term.setCursorPos(3,2)
print("Hello "..username.."!")
	sleep(3)
return false
else
term.setCursorPos(3,2)
print("Username Not FOUND!!!!")

return true
end

end
i = 0
repeat

term.setCursorPos(1,4)
print("+-------------------------+")
print("+ Enter Password!		 +")
print("+-------------------------+")
term.setCursorPos(3,2)

password = read("#")

if password == "ShutUp" then
   print("Acces Granted")
   sleep(4)
   startup()

   else
print("Acces Denied!")
sleep(2)
end
until i==3
end



--[[##############################################]]--








function menu(id, text)
if sid == id then
   write"> "
	elseif sid == 1 then
write""
end
print(text)
end

while true do

term.clear()
term.setCursorPos(2,1)
menu(0, "Login")
term.setCursorPos(2,2)
menu(1, "Exit")
event, key = os.pullEvent("key")
if key == 200 then
  if sid > 0 then
	 sid = sid - 1
end
elseif key == 208 then
   if sid < 1 then
	sid = sid + 1
end
elseif key == 28 then
  if sid == 0 then
  Logg1()
elseif sid == 0 then
return false



elseif sid == 1 then
os.shutdown()
end
return false
end

end





sjele #2
Posted 22 September 2012 - 06:17 PM
Try using the while loop more like this. Instead of a return to end it do something like this.

going = true
while going do
--Code to insert pw
if input == correctpass then
print("Access granted")
going = false
else
print("Wrong....")
end
end