Jump to content




Start Computer With A Password


  • This topic is locked This topic is locked
8 replies to this topic

#1 Bennievv

  • Members
  • 26 posts
  • LocationThe Netherlands

Posted 26 February 2012 - 12:29 PM

This is a script that locks your computer!

Type in the console:
edit startup
and type this code:
local funtion clearScreen()
term.clear()
term.setCursorPos(1,1)
end
while true do
clearScreen()
print("Welcome at ««YOUR NAME»» computer")
write"Password: "
if read("*") == "««PASSWORD»»" then
print("Correct password!")
sleep(1)
clearScreen()
shell.run("shell")
else
print("Incorrect password!")
sleep(2)
os.shutdown()
end
end

NOTE: You have to change ««YOUR NAME»» in your username and««PASSWORD»» into your password.

Another question:
Do anybody know how I can exit a program to the terminal


#2 Liraal

  • New Members
  • 477 posts
  • LocationPoland

Posted 26 February 2012 - 12:59 PM

return true


#3 Bennievv

  • Members
  • 26 posts
  • LocationThe Netherlands

Posted 26 February 2012 - 01:05 PM

View PostLiraal, on 26 February 2012 - 12:59 PM, said:

return true
:D/>

#4 luza

  • New Members
  • 43 posts
  • LocationGermany

Posted 26 February 2012 - 01:40 PM

you can easily bypass it by using ctrl + t.

#5 Bennievv

  • Members
  • 26 posts
  • LocationThe Netherlands

Posted 26 February 2012 - 01:54 PM

View Postluza, on 26 February 2012 - 01:40 PM, said:

you can easily bypass it by using ctrl + t.
Okay! :D/>

#6 Espen

    Curious Explorer

  • Members
  • 708 posts

Posted 26 February 2012 - 03:34 PM

View PostLiraal, on 26 February 2012 - 12:59 PM, said:

 return true 
That only works though if you call that from within the main program's scope, outside of any functions.
Or else your function will just return back to your main program.

If you're not planning on doing any exception handling in the future, then you could use a quick'n'dirty method and just throw an error wherever you want to exit your program:
function one( someVariable )
  -- Do something
  if someConditionIsMet then
	error("Program stopped ;-)")
  end
end

-- Main loop
while true do
  -- Do something
  one( someVariable )
end


#7 arjag

  • Members
  • 2 posts
  • LocationAdelaide, South Australia

Posted 21 January 2013 - 02:48 PM

gosh, took me way to long to spot the typo at the top where it says "funtion" instead of "function"

else
print("Incorrect password!")
sleep(2)
clearScreen()
sleep(4)
os.reboot()
end
end

I changed the end to this to make it reboot with a short delay instead of shutdown.

#8 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 21 January 2013 - 03:32 PM

I suggest adding os.pullEvent = os.pullEventRaw to the first line of your code to prevent termination. Other than that it looks like you are off to a good start with Lua!

#9 Cruor

  • Members
  • 413 posts
  • LocationNorway

Posted 22 January 2013 - 01:48 AM

Oh no! The necromancers are back D:
Locked to prevent the black magic from spreading.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users