Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local debugMode = true -- Set to false to prevent exiting to craftOS
- local pullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- Version = "Alpha [0.1]"
- function start()
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome to MackOs version " ..Version)
- term.setCursorPos(1,3)
- print("What would you like to do?")
- term.setCursorPos(1,4)
- print("[1] Login")
- term.setCursorPos(1,5)
- print("[2] Register")
- term.setCursorPos(1,6)
- print("[3] Reboot Computer")
- term.setCursorPos(1,7)
- print("[4] Shutdown Computer")
- term.setCursorPos(1,8)
- print("[5] Generate a password")
- term.setCursorPos(1,10)
- write("Input a number: ")
- local input = read()
- if input == "1" then
- login()
- elseif input == "2" then
- register()
- elseif input == "3" then
- term.clear()
- term.setCursorPos(1,1)
- print("Rebooting in 2 seconds!")
- sleep(2)
- os.reboot()
- elseif input == "4" then
- term.clear()
- term.setCursorPos(1,1)
- print("Shutting down in 2 seconds!")
- sleep(2)
- os.shutdown()
- elseif input == "5" then
- term.clear()
- term.setCursorPos(1,1)
- print("This is yet to be implemented")
- sleep(2)
- term.clear()
- start()
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Cant understand!")
- sleep(1)
- term.clear()
- start()
- end
- end
- function register()
- term.clear()
- term.setCursorPos(1,1)
- print("Registering")
- term.setCursorPos(1,3)
- write("Username: ")
- local usrName = read()
- term.setCursorPos(1,4)
- write("Password: ")
- local pass = read("*")
- fs.makeDir("users")
- local file = fs.open("users/"..usrName, "a")
- file.writeLine(pass)
- file.close()
- sleep(0.5)
- term.clear()
- term.setCursorPos(1,1)
- print("Registered!")
- sleep(0.5)
- term.clear()
- start()
- end
- function login()
- term.clear()
- term.setCursorPos(1,1)
- print("Logging in")
- term.setCursorPos(1,3)
- write("Username: ")
- usrName = read()
- write("Password: ")
- local pass = read("*")
- file = fs.open("users/"..usrName,"r")
- local fileData = {}
- local line = file.readLine()
- repeat
- table.insert(fileData, line)
- line = file.readLine()
- until line == nil -- readLine()
- file.close()
- local passFromFile = fileData[1]
- if pass == passFromFile then
- term.clear()
- term.setCursorPos(1,1)
- print("Login succeded!")
- sleep(1)
- term.clear()
- start2()
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Login failed!")
- sleep(1)
- term.clear()
- start()
- end
- end
- function start2()
- term.clear()
- term.setCursorPos(1,1)
- print("Running MackOs version " ..Version)
- term.setCursorPos(1,2)
- print("Logged in as " ..usrName)
- term.setCursorPos(1,4)
- print("[1] Logout")
- term.setCursorPos(1,5)
- print("[2] Calculator")
- term.setCursorPos(1,6)
- print("[3] Games")
- term.setCursorPos(1,7)
- print("[4] Delete account")
- term.setCursorPos(1,8)
- print("[5] Exit to CraftOs")
- term.setCursorPos(1,9)
- print("[6] Calendar (Made by TheOiginalBIT")
- local input = read()
- if input == "1" then
- term.clear()
- term.setCursorPos(1,1)
- print("Logging out")
- sleep(1)
- term.clear()
- start()
- elseif input == "2" then
- term.clear()
- term.setCursorPos(1,1)
- print("Starting Calulator")
- sleep(1)
- term.clear()
- sleep(0.1)
- calc()
- elseif input == "3" then
- term.clear()
- term.setCursorPos(1,1)
- print("Opening games")
- sleep(1)
- term.clear()
- games()
- elseif input == "4" then
- term.clear()
- term.setCursorPos(1,1)
- print("Opening delete function")
- sleep(1)
- term.clear()
- delacc()
- elseif input == "5" and debugMode then
- os.pullEvent = pullEvent
- term.clear()
- term.setCursorPos(1,1)
- print("You can press ctrl+t now")
- while true do os.pullEvent() end
- elseif input == "5" then
- term.clear()
- print("Starting calendar by TheOriginalBIT")
- sleep(1)
- term.clear()
- calendar()
- else
- term.clear()
- error1()
- end
- end
- function calendar()
- --[[
- Author: TheOriginalBIT
- Version: 1.1
- Created: 03 Feb 2013
- Last Update: 10 Mar 2013
- License:
- COPYRIGHT NOTICE
- Copyright © 2013 Joshua Asbury a.k.a TheOriginalBIT [
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement