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

(Tekkit classic version) Password

Started by Orb_29, 06 April 2015 - 07:15 AM
Orb_29 #1
Posted 06 April 2015 - 09:15 AM
Whatever I try to do wont work to create a startup password I think what I put was:
term.clear()
term.setCursorPos(1, 1)
print("test")
write("Please enter the code: ")
input = read("*")
if input == "Test" then
term.clear()
write("Welcome back!")
sleep(2)
end

else
term.clear()
write("WRONG!")

How can I create a password for startup so people cannot edit also what's the code for Ctrl + T being pulled
HPWebcamAble #2
Posted 06 April 2015 - 04:28 PM
If you put a disk in a disk drive next to a computer, it will run the startup on the disk instead of the startup on the computer, effectively bypassing it.

So keep in mind you can't secure a computer completely, but a password will deter anyone who doesn't know this.


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

local oldEvent = os.pullEvent --# Save the value of os.pullEvent
os.pullEvent = os.pullEventRaw --# Replace os.pullEvent with os.pullEventRaw so it can't be terminated
local input = ""


while true do --# Continues forever
  print("Enter the password:")
  term.write("> ")
  input = read("*") --# Prompts the user for input

  if input == "Test" then --# If the password is correct
    term.clear()
    term.setCursorPos(1,1)
    print("Welcome back!")
    break --# Ends the loop, and continues the code
  else --# User got it wrong
    print("WRONG!") 
  end
end

os.pullEvent = oldEvent --# Assign the old value back to os.pullEvent