FoxWorn3365

SfondoManager

Dec 5th, 2021 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.45 KB | None | 0 0
  1. term.setCursorPos(1, 1)
  2. term.setBackgroundColor(colors.white)
  3. term.clear()
  4.  
  5. -- Hack OS - v0.19
  6. -- By FoxWorn3365
  7.  
  8.  
  9. -- APPUNTI
  10. -- Configurazioni sistema: .localConf
  11. -- Configurazioni pubbliche: .publicConf
  12. -- Immagini: /Hack/images/
  13. -- APP: /Hack/programmi/
  14. -- App di esempio:
  15. -- Directory: /Hack/programmi/fileManager/
  16. -- Icona: /Hack/programmi/fileManager/app.ico
  17. -- File da eseguire: /Hack/programmi/fileManager/exec.luaDir
  18. -- Configurazioni (facoltativo) (OBBLIGO AUTOGENERAZIONE): /Hack/programmi/fileManager/conf.public
  19. -- Nome dell'APP (massimo 4 caratteri): /Hack/programmi/fileManager/app.name
  20. -- API: https://fcosma.it/hackos/api
  21.  
  22. maxw, maxh = term.getSize()
  23. local function drawPixelInternal(xPos, yPos)
  24. term.setCursorPos(xPos, yPos)
  25. term.write(" ")
  26. end
  27.  
  28. local tColourLookup = {}
  29. for n = 1, 16 do
  30. tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  31. end
  32.  
  33. function drawFilledBox(startX, startY, endX, endY, nColour)
  34. if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  35. "number" or type(endY) ~= "number" or
  36. (nColour ~= nil and type(nColour) ~= "number") then
  37. error("Expected startX, startY, endX, endY, colour", 2)
  38. end
  39.  
  40. startX = math.floor(startX)
  41. startY = math.floor(startY)
  42. endX = math.floor(endX)
  43. endY = math.floor(endY)
  44.  
  45. if nColour then term.setBackgroundColor(nColour) end
  46. if startX == endX and startY == endY then
  47. drawPixelInternal(startX, startY)
  48. return
  49. end
  50.  
  51. local minX = math.min(startX, endX)
  52. if minX == startX then
  53. minY = startY
  54. maxX = endX
  55. maxY = endY
  56. else
  57. minY = endY
  58. maxX = startX
  59. maxY = startY
  60. end
  61.  
  62. for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  63. end
  64.  
  65. function giremu(inputstr, sep)
  66. local t={}
  67. for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  68. table.insert(t, str)
  69. end
  70. return t
  71. end
  72.  
  73. function clear()
  74. sfondo(colors.black)
  75. term.clear()
  76. term.setCursorPos(1, 1)
  77. end
  78.  
  79. function clearRed()
  80. sfondo(colors.red)
  81. term.clear()
  82. term.setCursorPos(1, 1)
  83. end
  84.  
  85. function titolo(testo)
  86. drawFilledBox(1, 1, maxw, 1, colors.red)
  87. term.setCursorPos((maxw - #testo) / 2, 1)
  88. term.setTextColor(colors.white)
  89. term.write(testo)
  90. end
  91.  
  92. function alarm(testo, colore, y)
  93. drawFilledBox(1, y, maxw, y, colors[colore])
  94. term.setCursorPos((maxw - #testo) / 2, y)
  95. term.setTextColor(colors.white)
  96. term.write(testo)
  97. no()
  98. end
  99.  
  100. function modi(file, cont)
  101. local h = fs.open(file, "w")
  102. h.writeLine(cont)
  103. h.flush()
  104. h.close()
  105. end
  106.  
  107. function bottone(color, text, x, y)
  108. term.setBackgroundColor(colors[color])
  109. term.setTextColor(colors.white)
  110. term.setCursorPos(x, y)
  111. print(text)
  112. end
  113.  
  114. function drawA()
  115. term.setBackgroundColor(colors.white)
  116. term.setTextColor(colors.black)
  117. end
  118.  
  119. function ico(x, y, color, text)
  120. term.setBackgroundColor(colors[color])
  121. term.setTextColor(colors.white)
  122. term.setCursorPos(x, y)
  123. print(text)
  124. drawA()
  125. end
  126.  
  127. function menu()
  128. drawA()
  129. term.clear()
  130. titolo("Sfondo Manager")
  131. ico(51, 1, "gray", "X")
  132. end
  133.  
  134. don = 0
  135.  
  136. while true do
  137. if don == 0 then
  138. menu()
  139. print("\nSfondi in primo piano:")
  140. ico(10, 6, "orange", "VISIONE SU PONTE")
  141. ico(10, 8, "orange", "BANDIERA ARCOBALENO")
  142. local event, bt, x, y = os.pullEvent("mouse_click")
  143. if y == 1 and x == 51 then
  144. shell.run("desktop")
  145. elseif y == 6 and x > 10 then
  146. term.setTextColor(colors.green)
  147. print("Installo lo sfondo in /Hack/files/sfondi/ tra 3 secondi...")
  148. sleep(2)
  149. if fs.isDir("/Hack/files/sfondi") ~= true then
  150. shell.run("mkdir /Hack/files/sfondi")
  151. end
  152. shell.run("pastebin get CMVkYgkT /Hack/files/sfondi/sfondo_01")
  153. print("Installato! Nome file: sfondo_01")
  154. sleep(0.6)
  155. shell.run("desktop")
  156. elseif y == 8 and x > 10 then
  157. term.setTextColor(colors.green)
  158. print("Installo lo sfondo in /Hack/files/sfondi/ tra 3 secondi...")
  159. sleep(2)
  160. if fs.isDir("/Hack/files/sfondi") ~= true then
  161. shell.run("mkdir /Hack/files/sfondi")
  162. end
  163. shell.run("pastebin get aDViyJQG /Hack/files/sfondi/sfondo_02")
  164. print("Installato! Nome file: sfondo_02")
  165. sleep(0.6)
  166. shell.run("desktop")
  167. end
  168. end
  169. end
  170.  
Add Comment
Please, Sign In to add comment