Advertisement
Guest User

Linux OS

a guest
Feb 8th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. --Bootup
  2. print("LINUX OS V1.0")
  3. sleep(0.6)
  4. textutils.slowPrint("######################")
  5. sleep(0.9)
  6. --Log In
  7. while true do
  8. term.clear()
  9. term.setCursorPos(1, 1)
  10. print("User:")
  11. input = read("X")
  12. if input == "Karol" then
  13. while true do
  14. term.clear()
  15. term.setCursorPos(1, 1)
  16. print("Password:")
  17. input = read("X")
  18. if input == "Carlito2006" then
  19. --System
  20. term.clear()
  21. term.setCursorPos(1,1)
  22. term.setBackgroundColor( colors.green )
  23. textutils.slowPrint("Welcome, User!")
  24. texutils.slowPrint("What do you want to do?")
  25. --ButtonAPI
  26. local button={}
  27.  
  28. function clearTable()
  29. button = {}
  30. end
  31.  
  32. function setTable(name, func, param1, param2, active, xmin, xmax, ymin, ymax)
  33. button[name] = {}
  34. button[name]["func"] = func
  35. button[name]["active"] = active
  36. if active == nil then
  37. active = false
  38. end
  39. button[name]["param1"] = param1
  40. button[name]["param2"] = param2
  41. button[name]["xmin"] = xmin
  42. button[name]["ymin"] = ymin
  43. button[name]["xmax"] = xmax
  44. button[name]["ymax"] = ymax
  45. end
  46.  
  47. function remTable(name)
  48. button[name] = {}
  49. button[name]["xmin"] = 0
  50. button[name]["ymin"] = 0
  51. button[name]["xmax"] = 0
  52. button[name]["ymax"] = 0
  53. end
  54.  
  55.  
  56. function fill(text, color, bData)
  57. mon.setBackgroundColor(color)
  58. local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2)
  59. local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1
  60. for j = bData["ymin"], bData["ymax"] do
  61. mon.setCursorPos(bData["xmin"], j)
  62. if j == yspot then
  63. for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do
  64. if k == xspot then
  65. mon.write(text)
  66. else
  67. mon.write(" ")
  68. end
  69. end
  70. else
  71. for i = bData["xmin"], bData["xmax"] do
  72. mon.write(" ")
  73. end
  74. end
  75. end
  76. mon.setBackgroundColor(colors.black)
  77. end
  78.  
  79. function screen()
  80. local currColor
  81. for name,data in pairs(button) do
  82. local on = data["active"]
  83. if on == true then currColor = colors.lime else currColor = colors.red end
  84. fill(name, currColor, data)
  85. end
  86. end
  87.  
  88. function toggleButton(name)
  89. button[name]["active"] = not button[name]["active"]
  90. screen()
  91. end
  92.  
  93. function flash(name)
  94. toggleButton(name)
  95. screen()
  96. sleep(0.15)
  97. toggleButton(name)
  98. screen()
  99. end
  100.  
  101. function checkxy(x, y)
  102. for name, data in pairs(button) do
  103. if y>=data["ymin"] and y <= data["ymax"] then
  104. if x>=data["xmin"] and x<= data["xmax"] then
  105. if data["param1"] == "" then
  106. data["func"]()
  107. else
  108. data["func"](data["param1"], data["param2"])
  109. end
  110. return true
  111. end
  112. end
  113. end
  114. return false
  115. end
  116.  
  117. function heading(text)
  118. w, h = mon.getSize()
  119. mon.setCursorPos((w-string.len(text))/2+1, 1)
  120. mon.write(text)
  121. end
  122.  
  123. function label(w, h, text)
  124. mon.setCursorPos(w, h)
  125. mon.write(text)
  126. end
  127. end
  128. end
  129. end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement