26 posts
Location
The 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
473 posts
Location
Poland
Posted 26 February 2012 - 12:59 PM
26 posts
Location
The Netherlands
Posted 26 February 2012 - 01:05 PM
42 posts
Location
Germany
Posted 26 February 2012 - 01:40 PM
you can easily bypass it by using ctrl + t.
26 posts
Location
The Netherlands
Posted 26 February 2012 - 01:54 PM
you can easily bypass it by using ctrl + t.
Okay! :D/>/>
715 posts
Posted 26 February 2012 - 03:34 PM
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
2 posts
Location
Adelaide, 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.
1511 posts
Location
Pennsylvania
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!
389 posts
Location
Norway
Posted 22 January 2013 - 01:48 AM
Oh no! The necromancers are back D:
Locked to prevent the black magic from spreading.