lego11

ACC Tangara

Feb 8th, 2021 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.61 KB | None | 0 0
  1. function clear()
  2. term.clear()
  3. term.setCursorPos(1, 1)
  4. end
  5.  
  6. -- IMPLEMENTAZIONE DEL DRAWFILLEDBOX
  7. local function drawPixelInternal(xPos, yPos)
  8. term.setCursorPos(xPos, yPos)
  9. term.write(" ")
  10. end
  11.  
  12. local tColourLookup = {}
  13. for n = 1, 16 do
  14. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  15. end
  16.  
  17. function drawFilledBox(startX, startY, endX, endY, nColour)
  18. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  19. "number" or type(endY) ~= "number" or
  20. (nColour ~= nil and type(nColour) ~= "number") then
  21. error("Expected startX, startY, endX, endY, colour", 2)
  22. end
  23.  
  24. startX = math.floor(startX)
  25. startY = math.floor(startY)
  26. endX = math.floor(endX)
  27. endY = math.floor(endY)
  28.  
  29. if nColour then term.setBackgroundColor(nColour) end
  30. if startX == endX and startY == endY then
  31. drawPixelInternal(startX, startY)
  32. return
  33. end
  34.  
  35. local minX = math.min(startX, endX)
  36. if minX == startX then
  37. minY = startY
  38. maxX = endX
  39. maxY = endY
  40. else
  41. minY = endY
  42. maxX = startX
  43. maxY = startY
  44. end
  45.  
  46. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  47. end
  48.  
  49. function testo(sfumatura) term.setTextColour(sfumatura) end
  50.  
  51. function sfondo(sfumaturaSfondo) term.setBackgroundColour(sfumaturaSfondo) end
  52.  
  53. function disegnaDeviatoio(x, y, colore, lato)
  54. if colors.test(rs.getBundledInput("bottom"), colore) then
  55. term.setCursorPos(x, y)
  56. if lato == "dx" then
  57. term.write("/")
  58. else
  59. term.write("\\")
  60. end
  61. else
  62. term.setCursorPos(x, y)
  63. term.write("-")
  64. end
  65. end
  66.  
  67. function disegnaSegnale(x, y, colore)
  68. if colors.test(rs.getBundledInput("bottom"), colore) then
  69. paintutils.drawPixel(x, y, colors.lime)
  70. else
  71. paintutils.drawPixel(x, y, colors.red)
  72. end
  73. end
  74.  
  75. function disegnaSegnaleDoppio(x, y, colore1, colore2)
  76. if colors.test(rs.getBundledInput("bottom"), colore1) then
  77. paintutils.drawPixel(x, y, colors.red)
  78. paintutils.drawPixel(x, y+1, colors.lime)
  79. else
  80. paintutils.drawPixel(x, y, colors.lime)
  81. paintutils.drawPixel(x, y+1, colors.black)
  82. end
  83. end
  84.  
  85. function disegnaQLV()
  86. sfondo(colors.white)
  87. testo(colors.black)
  88. clear()
  89. term.setCursorPos(1, 1)
  90. qlv = paintutils.loadImage("qlv")
  91. paintutils.drawImage(qlv, 1, 1)
  92.  
  93. -- Segnali
  94. sfondo(colors.white)
  95. testo(colors.black)
  96. term.setCursorPos(5, 10)
  97. term.write("|")
  98. disegnaSegnale(5, 9, colors.white)
  99. sfondo(colors.white)
  100. testo(colors.black)
  101. term.setCursorPos(48, 10)
  102. term.write("|")
  103. disegnaSegnale(48, 9, colors.orange)
  104. sfondo(colors.white)
  105. testo(colors.black)
  106.  
  107. -- numeri binari
  108. testo(colors.green)
  109. term.setCursorPos(24, 10)
  110. term.write("II")
  111. term.setCursorPos(25, 12)
  112. term.write("I")
  113.  
  114. -- origini itinerari
  115. testo(colors.red)
  116. term.setCursorPos(2, 12)
  117. term.write("1")
  118. term.setCursorPos(47, 12)
  119. term.write("2")
  120.  
  121. --FV e destinazioni
  122. testo(colors.black)
  123. term.setCursorPos(2, 15)
  124. term.write("Thwolle F V PM Grottalupara")
  125.  
  126. --Pulsanti
  127. sfondo(colours.red)
  128. testo(colors.white)
  129. term.setCursorPos(2, 2)
  130. -- 2 -> 11, 2
  131. term.write(" TLBCA 1 ")
  132. term.setCursorPos(12, 2)
  133. -- 12 -> 21, 2
  134. term.write(" TLBCA 2 ")
  135. -- 22 -> 31, 2
  136. sfondo(colors.cyan)
  137. term.setCursorPos(2, 4)
  138. -- 2 -> 7, 4
  139. term.setCursorPos(2, 4)
  140. term.write(" 1-I ")
  141.  
  142. -- 7 -> 13, 4
  143. term.setCursorPos(8, 4)
  144. term.write(" 1-II ")
  145.  
  146. -- 15 -> 20, 4
  147. term.setCursorPos(15, 4)
  148. term.write(" 2-I ")
  149.  
  150. -- 21 -> 28, 4
  151. term.setCursorPos(21, 4)
  152. term.write(" 2-II ")
  153.  
  154. --Deviatoi
  155. --01
  156. sfondo(colors.gray)
  157. testo(colors.white)
  158. disegnaDeviatoio(7, 11, colors.magenta, "sx")
  159. --02
  160. disegnaDeviatoio(41, 11, colors.lime, "dx")
  161.  
  162.  
  163. end
  164.  
  165.  
  166.  
  167. function disegnaConferma(domanda)
  168. drawFilledBox(14, 8, 37, 14, colors.lightBlue)
  169. term.setCursorPos(15, 9)
  170. term.write("Eseguire il comando?")
  171. term.setCursorPos(15, 10)
  172. term.write(domanda)
  173. testo(colors.black)
  174. sfondo(colors.red)
  175. term.setCursorPos(16, 13)
  176. term.write(" No ")
  177. testo(colors.black)
  178. sfondo(colors.lime)
  179. term.setCursorPos(28, 13)
  180. term.write(" Si ")
  181. testo(colors.black)
  182. sfondo(colors.white)
  183.  
  184. local scelta = false
  185. while scelta == false do
  186. event, key, x, y = os.pullEvent("mouse_click")
  187. if event == "mouse_click" and x > 16 and x < 24 and y == 13 then
  188. scelta = true
  189. return false
  190. elseif event == "mouse_click" and x > 28 and x < 36 and y == 13 then
  191. scelta = true
  192. return true
  193. end
  194. end
  195. end
  196.  
  197. while true do
  198. disegnaQLV()
  199. event, par1, x, y = os.pullEvent()
  200. if event == "mouse_click" then
  201. if x < 11 and x > 2 and y == 2 and disegnaConferma("TLBCA 1") then
  202. rs.setBundledOutput("bottom", colors.pink)
  203. rs.setOutput("top", true)
  204. sleep(0.5)
  205. rs.setOutput("top", false)
  206. rs.setBundledOutput("bottom", 0)
  207. end
  208. if x < 21 and x > 12 and y == 2 and disegnaConferma("TLBCA 2") then
  209. rs.setBundledOutput("bottom", colors.lightGray)
  210. rs.setOutput("top", true)
  211. sleep(0.5)
  212. rs.setOutput("top", false)
  213. rs.setBundledOutput("bottom", 0)
  214. end
  215. if x < 7 and x > 2 and y == 4 then
  216. rs.setBundledOutput("bottom", colors.magenta)
  217. rs.setOutput("top", true)
  218. sleep(0.5)
  219. rs.setOutput("top", false)
  220. rs.setBundledOutput("bottom", 0)
  221. end
  222. if x < 13 and x > 8 and y == 4 then
  223. rs.setBundledOutput("bottom", colors.lightBlue)
  224. rs.setOutput("top", true)
  225. sleep(0.5)
  226. rs.setOutput("top", false)
  227. rs.setBundledOutput("bottom", 0)
  228. end
  229. if x < 20 and x > 15 and y == 4 then
  230. rs.setBundledOutput("bottom", colors.lime)
  231. rs.setOutput("top", true)
  232. sleep(0.5)
  233. rs.setOutput("top", false)
  234. rs.setBundledOutput("bottom", 0)
  235. end
  236. if x < 28 and x > 21 and y == 4 then
  237. rs.setBundledOutput("bottom", colors.yellow)
  238. rs.setOutput("top", true)
  239. sleep(0.5)
  240. rs.setOutput("top", false)
  241. rs.setBundledOutput("bottom", 0)
  242. end
  243. end
  244. end
Add Comment
Please, Sign In to add comment