Advertisement
Parlocameon

mfAPI

Mar 8th, 2015
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.86 KB | None | 0 0
  1. --MF stands for Multi Function
  2. --Author of API: CoolParker15
  3. --CC Forums: Pth1515
  4.  
  5. --..if you try running it(bugged)
  6. --print("THIS IS A API, NOT A PROGRAM!, Use os.loadAPI((location of file)) to load it. Also, to run a function type in mfAPI.(function (1,2,etc.)")
  7. --------------------------------------
  8.  
  9. --Functions
  10. --------------------------------------------------
  11. function download(url, name)
  12. local download = http.get(url)
  13. fstype = "w"
  14.  
  15. local data = download.readAll()
  16. download.close()
  17.  
  18. local file = fs.open(name, fstype)
  19. file.write(data)
  20. file.close()
  21.  
  22. print()
  23. print("Connected to: "..url)
  24. print()
  25. print("Downloaded: "..name)
  26. print()
  27. end
  28.  
  29. function clear()
  30. term.clear()
  31. term.setCursorPos(1,1)
  32. end
  33.  
  34. function osClear()
  35. --Clears screen and emulates boot up screen
  36. term.clear()
  37. term.setCursorPos(1,1)
  38. term.setTextColor(colors.yellow)
  39. print("CraftOS ".._CC_VERSION)
  40. term.setTextColor(colors.white)
  41. end
  42.  
  43. function cPrint(text, x, y)
  44. term.setCursorPos(x, y)
  45. print(text)
  46. end
  47.  
  48. function randomnum()
  49. number = math.random()
  50. print(number)
  51. end
  52.  
  53. function randomnum2(startnum, endnum)
  54. number = math.random(startnum, endnum)
  55. print(number)
  56. end
  57.  
  58. function login(username, password, ctc)
  59. os.pullEvent = os.pullEventRaw
  60. tonumber(ctc)
  61. term.setCursorPos(20,1)
  62. term.clear()
  63. print("Login:")
  64. term.setCursorPos(1,3)
  65. write("Username: ")
  66. p1 = read()
  67. print()
  68. write("Password: ")
  69. p2 = read("*")
  70. term.setCursorPos(14,1)
  71. term.clear()
  72. print("Checking Credentials...")
  73. sleep(3)
  74. if p1 == username and p2 == password then
  75. term.setCursorPos(18,1)
  76. term.clear()
  77. term.setTextColor(colors.green)
  78. print("Access Granted")
  79. sleep(3)
  80. term.setCursorPos(1,1)
  81. term.clear()
  82. term.setTextColor(ctc)
  83. print("Welcome, "..username..".")
  84. print()
  85. else
  86. term.setCursorPos(18,1)
  87. term.clear()
  88. term.setTextColor(colors.red)
  89. print("Access Denied")
  90. sleep(3)
  91. os.reboot()
  92. end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement