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

Need help with login program

Started by Krul__Tepes, 20 July 2017 - 04:59 AM
Krul__Tepes #1
Posted 20 July 2017 - 06: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
Lupus590 #2
Posted 20 July 2017 - 10:45 AM
What does it do and what do you want it to do?

also
 tags
close with [[i][/i]/code]
Edited on 20 July 2017 - 09:27 AM
Krul__Tepes #3
Posted 20 July 2017 - 11:57 AM
its suppost to be a computer lock like
username:
Password:
KingofGamesYami #4
Posted 20 July 2017 - 12:01 PM
You need () after read, or you're literally comparing a function to a string.
Krul__Tepes #5
Posted 20 July 2017 - 12:04 PM
i added () after read but it says
bios:14: [string " .temp"]: 10: 'then' expected
Krul__Tepes #6
Posted 20 July 2017 - 01:22 PM
any suggestion on how to fix that?
KingofGamesYami #7
Posted 20 July 2017 - 02:29 PM
To compare things, you need to use ==, not just =.
Krul__Tepes #8
Posted 20 July 2017 - 03: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
Krul__Tepes #9
Posted 20 July 2017 - 03: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
Krul__Tepes #10
Posted 20 July 2017 - 04:24 PM
again i fixed it xD