Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. local term = require("term")
  2. local os = require("os")
  3. local component = require("component")
  4. local event = require("event")
  5.  
  6. username = "roxox1"
  7. password = "reece"
  8. isLoggedIn = false
  9.  
  10. function clear()
  11. term.clear()
  12. end
  13.  
  14. function login()
  15. if isLoggedIn == true then mainMenu() end --In case we somehow get here by mistake
  16. clear()
  17. print("Username: ")
  18. usernameentered = io.read()
  19. print("Password: ")
  20. passwordentered = io.read()
  21. if usernameetered == username then
  22. if passwordentered == password then
  23. isLoggedIn = true
  24. end
  25. end
  26. if isLoggedIn == true then mainMenu() end
  27. if isLoggedIn == false then print("Nope") os.sleep(2) login() end
  28. end
  29.  
  30. function mainMenu()
  31. clear()
  32. print("--------------------")
  33. print("(1) Check resources")
  34. print("(2) Craft items")
  35. print("(3) Check Power")
  36. print("(4) Logout")
  37. print("(5) Close Program")
  38. print("--------------------")
  39. input = io.read()
  40.  
  41. if input == "1" then checkResources() end -- Check resources
  42. if input == 2 then print("(2)") end -- Craft Items
  43. if input == '3' then checkPower() end
  44. if input == '4' then logout() end
  45. if input == '5' then closeProgram() end
  46. end
  47.  
  48. function checkResources()
  49. itemTable = {}
  50. print("Opening listening port 888..")
  51. if component.modem.open(888) then
  52. print("Port 888 is open.")
  53. else
  54. print("Something went wrong :(")
  55. component.modem.close(888)
  56. mainMenu()
  57. end
  58. local function addItemsToTable(_, _, _, _, _, itemData)
  59. myTable = serialization.unserialize(itemData)
  60. for x,y in pairs(myTable) do print(key, value) end
  61. end
  62. event.listen("modem_message", addItemsToTable)
  63. a = io.read()
  64. end
  65.  
  66. function checkPower()
  67. clear()
  68. print(component.RotationalDynamo.getPower())
  69. e = io.read()
  70. mainMenu()
  71. end
  72. function logout() -- Logout
  73. isLoggedIn = false
  74. login()
  75. end
  76.  
  77. function closeProgram() -- Close Program
  78. clear()
  79. end
  80.  
  81. mainMenu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement