Advertisement
lego11

Fabrimat TDS

Jun 30th, 2021 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. --VARIABILI DA POPOLARE
  2.  
  3. apiVersion = "NaN"
  4. progVersion = "v1.0"
  5. defconLvl = "DEFCON 5"
  6. isEndorOn = true
  7. message = "Questo รจ un messaggio generico"
  8.  
  9. function updateVars()
  10. apiVersion = "NaN"
  11. progVersion = "v1.0"
  12. defconLvl = "DEFCON 5"
  13. isEndorOn = false
  14. message = "Questo รจ un messaggio generico"
  15. end
  16.  
  17. maxw, maxh = term.getSize()
  18. halfw = math.floor(maxw/2)
  19. halfh = math.floor(maxh/2)
  20.  
  21. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  22. local function drawPixelInternal(xPos, yPos)
  23. term.setCursorPos(xPos, yPos)
  24. term.write(" ")
  25. end
  26.  
  27. local tColourLookup = {}
  28. for n = 1, 16 do
  29. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  30. end
  31.  
  32. function drawFilledBox(startX, startY, endX, endY, nColour)
  33. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  34. "number" or type(endY) ~= "number" or
  35. (nColour ~= nil and type(nColour) ~= "number") then
  36. error("Expected startX, startY, endX, endY, colour", 2)
  37. end
  38.  
  39. startX = math.floor(startX)
  40. startY = math.floor(startY)
  41. endX = math.floor(endX)
  42. endY = math.floor(endY)
  43.  
  44. if nColour then term.setBackgroundColor(nColour) end
  45. if startX == endX and startY == endY then
  46. drawPixelInternal(startX, startY)
  47. return
  48. end
  49.  
  50. local minX = math.min(startX, endX)
  51. if minX == startX then
  52. minY = startY
  53. maxw = endX
  54. maxh = endY
  55. else
  56. minY = endY
  57. maxw = startX
  58. maxh = startY
  59. end
  60.  
  61. for x = minX, maxw do for y = minY, maxh do drawPixelInternal(x, y) end end
  62. end
  63.  
  64. function colore(sfumatura) term.setTextColour(sfumatura) end
  65.  
  66. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  67.  
  68. function fineColore() term.setTextColour(colours.white) end
  69.  
  70. function fineSfondo() term.setBackgroundColour(colours.black) end
  71.  
  72. function titolo(testo)
  73. maxw, maxh = term.getSize()
  74. drawFilledBox(1, 1, maxw, 1, colors.yellow)
  75. term.setCursorPos((maxw - #testo) / 2, 1)
  76. colore(colors.black)
  77. term.write(testo)
  78. end
  79.  
  80. function clear()
  81. term.clear()
  82. term.setCursorPos(1,1)
  83. end
  84.  
  85. function printCentered(text)
  86. local curx, cury = term.getCursorPos()
  87. local maxw, maxh = term.getSize()
  88. term.setCursorPos((maxw - #text) / 2, cury)
  89. term.write(text)
  90. term.setCursorPos(curx, cury + 1)
  91. end
  92.  
  93.  
  94. function drawMain()
  95. titolo("Tyrian Defense System")
  96. drawFilledBox(halfw - 9, halfh, halfw + 9, halfh + 2, colors.lime)
  97. term.setCursorPos(1, halfh+1)
  98. printCentered("Richiesta accesso")
  99. term.setBackgroundColor(colors.black)
  100. term.setTextColor(colors.white)
  101.  
  102. term.setCursorPos(1, halfh/2)
  103.  
  104. local defconLvls = {}
  105. defconLvls["DEFCON 1"] = colors.red
  106. defconLvls["DEFCON 2"] = colors.yellow
  107. defconLvls["DEFCON 3"] = colors.lime
  108. defconLvls["DEFCON 4"] = colors.cyan
  109. defconLvls["DEFCON 5"] = colors.purple
  110. colore(defconLvls[defconLvl])
  111. printCentered(defconLvl)
  112.  
  113. term.setCursorPos(1, halfh/2 + 2)
  114. colore(colors.white)
  115. if isEndorOn == false then
  116. printCentered("ENDOR non attivo")
  117. else
  118. printCentered("ENDOR attivo")
  119. end
  120.  
  121. maxw, maxh = term.getSize()
  122. local versionString = "(C) Proclus & Albannach 2021 - " .. progVersion .. " - API " .. apiVersion .. " "
  123. term.setCursorPos(1, maxh)
  124. printCentered(versionString)
  125. end
  126.  
  127. function drawMessage()
  128. clear()
  129. titolo("Tyrian Defense System")
  130. term.setBackgroundColor(colors.black)
  131. term.setTextColor(colors.white)
  132.  
  133. term.setCursorPos(1, halfh)
  134.  
  135. printCentered(message)
  136.  
  137. maxw, maxh = term.getSize()
  138. local versionString = "(C) Proclus & Albannach 2021 - " .. progVersion .. " - API " .. apiVersion .. " "
  139. term.setCursorPos(1, maxh)
  140. printCentered(versionString)
  141. end
  142.  
  143.  
  144. function func_484192a()
  145. drawMessage()
  146. os.pullEvent()
  147. end
  148.  
  149. clear()
  150.  
  151. while true do
  152. updateVars()
  153. drawMain()
  154. event, button, x, y = os.pullEvent("mouse_click")
  155. term.setCursorPos(1, 17)
  156. if x >= (halfw - 9) and x <= (halfw + 9) and y <= (halfh + 2) and y >= (halfh) then
  157. func_484192a()
  158. break
  159. end
  160. end
  161.  
  162.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement