Jump to content




Need help with login program


  • You cannot reply to this topic
9 replies to this topic

#1 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 05:59 AM

this is basically my first try at programming and the program is based off another i found heres the code i cant seem to get it to work

local color = colors.red

while true do
oldPull = os.pullEventRaw
term.clear()
term.setCursorPos(1,1)
term.setTextColor(color)
print("Zphone")
write("Username: ")
if read = "username" then
write(Password: ")
read("*") = "password" then
sleep(1)
term.clear()
term.setCursorPos(1,1)
else
print("Incorrect Login Details")
sleep()
print("Rebooting...")
sleep(1)
end
end
os.pullEvent = oldPull

know me this is probably horrible

#2 Lupus590

  • Members
  • 2,028 posts
  • LocationUK

Posted 20 July 2017 - 09:45 AM

What does it do and what do you want it to do?

also [code] tags
close with [/code]

Edited by Bomb Bloke, 20 July 2017 - 10:27 AM.


#3 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 10:57 AM

its suppost to be a computer lock like
username:
Password:

#4 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 20 July 2017 - 11:01 AM

You need () after read, or you're literally comparing a function to a string.

#5 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 11:04 AM

i added () after read but it says
bios:14: [string " .temp"]: 10: 'then' expected

#6 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 12:22 PM

any suggestion on how to fix that?

#7 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 20 July 2017 - 01:29 PM

To compare things, you need to use ==, not just =.

#8 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 02:08 PM

i fixed it now i have another problem
im getting <eof> expected at line 34 i changed the code heres the new code for the ending

if read("*") == "password" then
print("Welcome")
sleep(1)
term.clear()
term.setCursorPos(1,1)
end
else
print("Incorrect Loging Details")
sleep()
print("Rebooting...")
sleep(1)
end

os.pullEvent = oldPull

nvm fixed that NOW i have a different problem xD

im trying to get it you type where i have write("Password: ")
but its typing at the bottom of the screen

#9 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 02:37 PM

figured that out too NOW i have another problem

when i get the password wrong i have it reboot but when it reboots where i type the password goes to where i have the user at

#10 Krul__Tepes

  • Members
  • 17 posts

Posted 20 July 2017 - 03:24 PM

again i fixed it xD





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users