C07v0

DynationOS beta 1.6

Mar 15th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.24 KB | None | 0 0
  1. --[ Made by "Kolten *****" a.k.a "Spongy141"
  2. -- Progam may be ONLY used as allowed
  3. -- You may not edit without permission,
  4. -- You may use DynationOS as a OS for ComputerCraft
  5. -- Credit for DynationOS
  6. -- Kolten ***** a.k.a "Spongy141" for making DynationOS
  7. -- Shnupbups100 for CCScreensaver
  8. --]
  9.  
  10. function start()
  11.   term.clear()
  12.   term.setCursorPos(1,1)
  13.   term.setTextColor(colors.yellow)
  14.   print("DynationOS")
  15.   term.setTextColor(colors.lightBlue)
  16.   textutils.slowPrint("DynationOS, making things easy.")
  17.   term.setTextColor(colors.white)
  18. end
  19.  
  20. function button()
  21.   local tCoords = {
  22.     [1] = { 36, 50, 15, 16, "Create Account" },
  23.     [2] = { 2, 7, 15, 16, "Login" },
  24.   }
  25.  
  26.   term.setCursorPos(36,15)
  27.   print("Create Account")
  28.   term.setCursorPos(2,15)
  29.   print("Login")
  30.   term.setCursorPos(1,3)
  31.  
  32.   local evt, button, x, y = os.pullEvent("mouse_click")
  33.  
  34.   for i = 1, #tCoords do
  35.     if x >= tCoords[i][1] and x <= tCoords[i][2] and y >= tCoords [i][3] and y <= tCoords [i][4] then
  36.       button = i
  37.       setup()
  38.       break
  39.     end
  40.   end
  41.  
  42.   for i = 2, #tCoords do
  43.     if x >= tCoords[i][1] and x <= tCoords[i][2] and y >= tCoords [i][3] and y <= tCoords [i][4] then
  44.       button = i
  45.       clickUsername()
  46.       break
  47.     end
  48.   end
  49. end
  50.  
  51. function name()
  52.   local file = fs.open("file.username","r")
  53.   local user = {file.readLine()}
  54.   file.close()
  55.   return user
  56. end
  57.  
  58. function password()
  59.   local file = fs.open("file.password","r")
  60.   local pass = {file.readLine()}
  61.   file.close()
  62.   return pass
  63. end
  64.  
  65. function clickUsername()
  66.   start()
  67.   term.setCursorPos(14,14)
  68.   print("Accounts")
  69.   term.setCursorPos(21,9)
  70.   local username = {name()}
  71.   print(username)
  72.   term.setCursorPos(1,3)
  73.  
  74.   local sCoords = {
  75.     [1] = { 21, 30, 9, 10, "Spongy" },
  76.   }
  77.  
  78.   local evt, button, x, y = os.pullEvent("mouse_click")
  79.   for i = 1, #sCoords do
  80.     if x >= sCoords[i][1] and x <= sCoords[i][2] and y >= sCoords[i][3] and y <= sCoords[i][4] then
  81.       button = i
  82.       login()
  83.       break
  84.     end
  85.   end
  86.    
  87. end
  88.  
  89. function login()
  90.   local usernameX = {name()}
  91.   term.setTextColor(colors.lime)
  92.   print("Welcome ",usernameX," you will need to type in your password")
  93.   password()
  94.   term.write("Password: ")
  95.   term.setTextColor(colors.white)
  96.   local passw = read()
  97.   if passw == (pass) then
  98.     User()
  99.   else
  100.   term.setTextColor(colors.red)
  101.   print("Wrong Password, redirecting you back to start menu")
  102.   sleep(2)
  103.   term.setTextColor(colors.white)
  104.   button()
  105.   end
  106. end
  107.  
  108. function setup()
  109.   term.setTextColor(colors.lime)
  110.   print("Welcome to DynationOS setup program, today you will be setting up your DynationOS!")
  111.   print("(Please quote your info) First, what is your name?: ")
  112.   term.setTextColor(colors.white)
  113.   local name = read()
  114.   file = fs.open("/DOS/file.username","w")
  115.   file.writeLine('("'..user..'")')
  116.   term.setTextColor(colors.lime)
  117.   print("Alright ",name,", what would you like your password to be?: ")
  118.   term.setTextColor(colors.white)
  119.   file.close()
  120.   file = fs.open("/DOS/file.password","w")
  121.   local pass = read()
  122.   file.writeLine('("'..pass..'")')
  123.   file.close()
  124.   term.setTextColor(colors.lime)
  125.   print("Alright ",name,", would you like to use rednet (yes or no): ")
  126.   term.setTextColor(colors.white)
  127.   local ans = read()
  128.   if ans == ("yes") then
  129.     term.setTextColor(colors.lime)
  130.     print("Alright where is your wireless modem located?: ")
  131.     term.setTextColor(colors.white)
  132.     file = fs.open("/DOS/file.rednet","w")
  133.     local side = read()
  134.     rednet.open(side)
  135.     file.writeLine("local rednet = true")
  136.     term.setTextColor(colors.lime)
  137.     print("Well this is the end of the setup, goodbye!")
  138.     file.close()
  139.     start()
  140.    elseif ans == ("no") then
  141.     term.setTextColor(colors.lime)
  142.     print("Alright",name,", I will turn off rednet mode, NOTE: Call me Simple")
  143.     file.writeLine("local rednet = false")
  144.     print("Well this is the end of the setup, goodbye!")
  145.     sleep(1)
  146.     file.close()
  147.     start()
  148.   end
  149. end
  150.  
  151. function User()  -- All this does is let the player do commands
  152.   term.setTextColor(colors.brown)
  153.   print("Please enter: help  : if you need help")
  154.   while true do
  155.     term.setTextColor(colors.lime)
  156.     write("Command: ")
  157.     term.setTextColor(colors.white)
  158.     local cmd = read()
  159.     if cmd == ("help") then
  160.       term.setTextColor(colors.brown)
  161.       print("Commands are: ")
  162.       write("help :")
  163.       term.setTextColor(colors.lightBlue)
  164.       print("This is the help command")
  165.       term.setTextColor(colors.brown)
  166.       print("No more commands ATM, since I'm lazy")
  167.     end
  168.    
  169.     if cmd == ("Music.add") then
  170.       term.setTextColor(colors.lightBlue)
  171.       write("What side is the new music disk on?: ")
  172.       term.setTextColor(colors.white)
  173.       local sidesong = read()
  174.       term.setTextColor(colors.blue)
  175.       textutils.slowPrint("...........",0.8)
  176.       sleep(0.5)
  177.       textutils.slowPrint("Testing new song")
  178.       shell.run("dj","play ",side)
  179.       sleep(3)
  180.       shell.run("dj","stop")
  181.       print("Test Complete, if no sound then please retry")
  182.       print("If you heard sound then please enter the name (can be anything)")
  183.       write("Name: ")
  184.       term.setTextColor(colors.white)
  185.       local name = read()
  186.       file = fs.open("songs","w")
  187.       file.writeLine("local song = (",name,")")
  188.       file.close()
  189.     end
  190.    
  191.     if cmd == ("exit") then
  192.       os.exit()
  193.     end
  194.     if cmd == ("time") then
  195.       os.time(times)
  196.       print(times)
  197.       else
  198.     end
  199.     function setAlarm()
  200.       term.setTextColor(colors.yellow)
  201.       print("What time will you want your alarm to go off at?")
  202.       os.clock(clocks)
  203.       print(clocks)
  204.       term.write("Alarm Time: ")
  205.       term.setTextColor(colors.white)
  206.       local AlarmTime = read()
  207.       os.setAlarm(AlarmTime)
  208.     end
  209.    
  210.     if cmd == ("set alarm") then
  211.       setAlarm()
  212.     end
  213.    
  214.     if cmd == ("") then
  215.       term.setTextColor(colors.red)
  216.       print("Please enter a valid command")
  217.     end
  218.    
  219.     if cmd == ("69") then  -- this was for earler testing of mine for me to get back to the setup function..
  220.       term.setTextColor(colors.red)
  221.       print("Thats not a command...")
  222.       sleep(0.2)
  223.       print("Being redirected to setup.")
  224.       sleep(1)
  225.       setup()
  226.     end
  227.    
  228.     if cmd == ("afk") then
  229.       term.setTextColor(colors.lime)
  230.       term.write("What would you like your screen saver to be?: ")
  231.       term.setTextColor(colors.white)
  232.       local screen = read()
  233.       shell.run("/DOS/screensaver","-u" ..screen)
  234.     end
  235.    
  236.   end
  237. end
  238.  
  239. start()
  240. button()
Advertisement
Add Comment
Please, Sign In to add comment