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

My comp code error

Started by bloodstabber, 06 August 2012 - 03:29 AM
bloodstabber #1
Posted 06 August 2012 - 05:29 AM
Print "welcome to bloodstabbers pc please enter username"
Input = read()
If input == "bloodstabber" then
Print "welcome bloodstabber"
Sleep(3)
Print "please enter your password
Input = read("*")
If input == "SourCow" then
Sleep(2)
Print "welcome to your computer, bloodstabber!"
Else
Print "you are not the owner of this pc! Please leave!"
Sleep(5)
Os.reboot
End

I tried my best but it keeps giving me stupid errors like it needs = at end or it wants = at end of line 3 please help it would sure help me :P/>/>
Zalerinian #2
Posted 06 August 2012 - 06:10 AM
Print "welcome to bloodstabbers pc please enter username"
Input = read()
If input == "bloodstabber" then
Print "welcome bloodstabber"
Sleep(3)
Print "please enter your password
Input = read("*")
If input == "SourCow" then
Sleep(2)
Print "welcome to your computer, bloodstabber!"
Else
Print "you are not the owner of this pc! Please leave!"
Sleep(5)
Os.reboot
End

I tried my best but it keeps giving me stupid errors like it needs = at end or it wants = at end of line 3 please help it would sure help me :P/>/>

Can you specify what the error is? or is it saying you do need a '=' at line 3?
kotorone1 #3
Posted 06 August 2012 - 06:12 AM
hello, here is a script that should work.
Spoiler

term.clear()
term.setCursorPos(1,1)
local tTrue = true
local aTrue = true
print("Welcom to bloodstabber's PC. Please enter username:")
function pick1()
while tTrue == true do
  input = read()
  if input == "bloodstabber" then
   print("Please enter your password:")
   tTrue = false
   pick2()
  else
  end
end
end
function pick2()
while aTrue == true do
  input2 = read("*")
  if input2 == "SourCow" then
   print("Welcome bloodstabber")
   aTrue = false
   --do something here
  else
   print("You do not own this PC. Please leave")
   sleep(5)
   os.reboot()
  end
end
end
pick1()
Lyqyd #4
Posted 06 August 2012 - 06:52 AM
Print "welcome to bloodstabbers pc please enter username"
Input = read()
If input == "bloodstabber" then
Print "welcome bloodstabber"
Sleep(3)
Print "please enter your password
Input = read("*")
If input == "SourCow" then
Sleep(2)
Print "welcome to your computer, bloodstabber!"
Else
Print "you are not the owner of this pc! Please leave!"
Sleep(5)
Os.reboot
End

I tried my best but it keeps giving me stupid errors like it needs = at end or it wants = at end of line 3 please help it would sure help me :P/>/>

Lua is an interpreted computer language, not English. It's case sensitive, so when you capitalize the first letter of the line, you're changing what it does. "If" and "if" are completely different.
KevinW1998 #5
Posted 06 August 2012 - 06:53 AM
You should add OS.pullEvent = OS.pullEventRaw to make it termination-safe
bloodstabber #6
Posted 06 August 2012 - 07:40 AM
Well guys i figured it out WAY before you responded i figured i need to ends so i can have multiple cases
Thanks anyway