Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Required Imports
- local libs = require("libs")
- --
- --verables
- local password_true = "God"
- --
- -- Define the "main" function
- -- This is the function we want to "protect"
- local function main()
- local hash_ = "7a0c0b6d"
- if checkFileHash("disk/authenticate", hash_) then
- --sleep(0.2)
- else
- term.clear() -- clears the terminal
- term.setCursorPos(1,1) -- sets cursor postion
- printError("Security Check Failed! - Shutdown") -- prints a error message
- pcall(sleep, 5) -- sleeps for 5 seconds
- os.shutdown() -- shutdown CraftOS
- end
- while true do
- term.clear()
- term.setCursorPos(1, 1)
- write("Password:")
- local password = read("*")
- if password == password_true then
- return
- else
- printError("Incorrect password.")
- pcall(sleep, 5)
- end
- end
- end
- local leaveloop = true
- while leaveloop do
- local ok, err = pcall(main) -- protectedly call main
- if ok then
- -- Correct password was entered!
- -- do whatever you want here
- --term.clear()
- --term.setCursorPos(1, 1)
- --shell.run("src_main.lua")
- leaveloop = false
- else
- -- There was an error! The contents of the error are stored in "err"
- if err == "Terminated" then
- printError("\nSorry, but we can't have you terminating this now can we?")
- leaveloop = true
- pcall(sleep, 2) -- pcall the sleep function since it is also terminateable.
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement