Advertisement
FoxWorn3365

Settings - Hack OS

Dec 4th, 2021 (edited)
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.27 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.lightGray)
  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.  
  101. function bottone(x, y, color, text)
  102. term.setBackgroundColor(colors[color])
  103. term.setTextColor(colors.white)
  104. term.setCursorPos(x, y)
  105. print(text)
  106. end
  107.  
  108. function drawA()
  109. term.setBackgroundColor(colors.white)
  110. term.setTextColor(colors.black)
  111. end
  112.  
  113. function ico(x, y, color, text)
  114. term.setBackgroundColor(colors[color])
  115. term.setTextColor(colors.white)
  116. term.setCursorPos(x, y)
  117. print(text)
  118. end
  119.  
  120. function pulisci()
  121. drawA()
  122. term.clear()
  123. term.setCursorPos(1, 1)
  124. end
  125.  
  126. don = 0
  127.  
  128. while true do
  129. if don == 0 then
  130. pulisci()
  131. titolo("Hack OS - Impostazioni")
  132. drawA()
  133. ico(51, 1, "red", "X")
  134. print("\nImpostazioni del Computer")
  135. bottone(5, 5, "gray", "Cambia il Nome")
  136. bottone(5, 6, "gray", "Cambia la Password")
  137. bottone(5, 7, "gray", "Imposta uno Sfondo (IMAGE)")
  138. bottone(5, 8, "gray", "Imposta uno Sfondo (COLOR)")
  139. bottone(5, 10, "green", "Aggiorna Hack Desktop")
  140. bottone(5, 12, "green", "Aggiorna Hack Store")
  141. bottone(5, 14, "orange", "Aggiorna Impostazioni")
  142. bottone(5, 16, "red", "Reinstalla Hack OS")
  143.  
  144. local event, bt, x, y = os.pullEvent("mouse_click")
  145. if y == 1 and x == 51 then
  146. shell.run("desktop")
  147. elseif y == 5 then
  148. don = 1
  149. elseif y == 6 then
  150. don = 2
  151. elseif y == 7 then
  152. don = 3
  153. elseif y == 8 then
  154. don = 4
  155. elseif y == 16 then
  156. shell.run("pastebin get DVXwL6uV /init")
  157. shell.run("rm /Hack/")
  158. shell.run("/init")
  159. elseif y == 14 then
  160. shell.run("rm /Hack/programmi/settings/exec.luaDir")
  161. shell.run("pastebin get EKH7AzbK /Hack/programmi/settings/exec.luaDir")
  162. elseif y == 10 then
  163. shell.run("rm /startup")
  164. shell.run("rm /desktop")
  165. shell.run("pastebin get AQX6gG3e /startup")
  166. shell.run("pastebin get ZyEEJig6 /desktop")
  167. term.setTextColor(colors.lime)
  168. print("Hack OS aggiornato! Riavvio in 3 secondi")
  169. sleep(2)
  170. shell.run("reboot")
  171. elseif y == 12 then
  172. shell.run("rm /Hack/programmi/store/exec.luaDir")
  173. shell.run("pastebin get B0TnDgED /Hack/programmi/store/exec.luaDir")
  174. term.setTextColor(colors.lime)
  175. print("Hack Store aggiornato! Riavvio in 3 secondi")
  176. sleep(2)
  177. shell.run("reboot")
  178. end
  179. elseif don == 1 then
  180. pulisci()
  181. titolo("Hack OS - Impostazioni")
  182. drawA()
  183. print("\n\n\nInserisci il nuovo nome:")
  184. nName = read()
  185. local h = fs.open("/.localConf", "r")
  186. oldConf = giremu(h.readAll(), "$")
  187. h.close()
  188. shell.run("rm /.localConf")
  189. local h = fs.open("/.localConf", "w")
  190. if nName == nil or nName == '' then
  191. h.writeLine("HackOS-PC$"..oldConf[2].."$"..oldConf[3])
  192. else
  193. h.writeLine(nName.."$"..oldConf[2].."$"..oldConf[3])
  194. end
  195. h.flush()
  196. h.close()
  197. term.setTextColor(colors.lime)
  198. print("\nFatto! Riavvio tra 3 secondi...")
  199. sleep(2)
  200. shell.run("reboot")
  201. elseif don == 2 then
  202. pulisci()
  203. titolo("Hack OS - Impostazioni")
  204. drawA()
  205. print("\n\n\nInserisci la nuova password:")
  206. nPass = read()
  207. local h = fs.open("/.localConf", "r")
  208. oldConf = giremu(h.readAll(), "$")
  209. h.close()
  210. shell.run("rm /.localConf")
  211. local h = fs.open("/.localConf", "w")
  212. if nPass ~= nil or nPass ~= '' then
  213. h.writeLine(oldConf[1].."$"..oldConf[2].."$"..nPass)
  214. else
  215. h.writeLine(oldConf[1].."$"..oldConf[2])
  216. end
  217. h.flush()
  218. h.close()
  219. term.setTextColor(colors.lime)
  220. print("\nFatto! Riavvio tra 3 secondi...")
  221. sleep(2)
  222. shell.run("reboot")
  223. elseif don == 3 then
  224. pulisci()
  225. titolo("Hack OS - Impostazioni")
  226. drawA()
  227. print("\n\n\nRICORDA! L'immagine deve essere nella directory /Hack/files/!\nInserisci il file: (metti null per rimuovere)")
  228. nBkg = read()
  229. if nBkg ~= "null" then
  230. if fs.exists("/Hack/files/"..nBkg) == true then
  231. shell.run("rm /.bkgConf")
  232. local h = fs.open("/.bkgConf", "w")
  233. h.write(nBkg)
  234. h.flush()
  235. h.close()
  236. term.setTextColor(colors.lime)
  237. print("\nFatto! Riavvio tra 3 secondi...")
  238. sleep(1.5)
  239. shell.run("reboot")
  240. else
  241. print("\nVuoto! Riavvio tra 3 secondi...")
  242. sleep(1.5)
  243. shell.run("reboot")
  244. end
  245. elseif nBkg == nil or nBkg == "" then
  246. shell.run("/Hack/programmi/settings/exec.luaDir")
  247. else
  248. shell.run("rm /.bkgConf")
  249. shell.run("/Hack/programmi/settings/exec.luaDir")
  250. end
  251. elseif don == 4 then
  252. pulisci()
  253. titolo("Hack OS - Impostazioni")
  254. drawA()
  255. print("\n\n\nInserisci il colore:")
  256. nCll = read()
  257. if nCll ~= "green" and nCll ~= "red" and nCll ~= "white" and nCll ~= "blue" and nCll ~= "aqua" and nCll ~= "orange" and nCll ~= "black" and nCll ~= "gray" and nCll ~= "lime" ~= "cyan" then
  258. print("\nCOLORE INVALIDO!\nVerrai reindirizzato tra 3 secondi...")
  259. sleep(1)
  260. shell.run("/Hack/programmi/settings/exec.luaDir")
  261. else
  262. if nCll ~= nil or nCll ~= "" then
  263. shell.run("rm /.bkgColor")
  264. local h = fs.open("/.bkgColor", "w")
  265. h.write(nCll)
  266. h.flush()
  267. h.close()
  268. term.setTextColor(colors.lime)
  269. print("\nFatto! Riavvio tra 3 secondi...")
  270. sleep(2)
  271. shell.run("reboot")
  272. else
  273. shell.run("/Hack/programmi/settings/exec.luaDir")
  274. shell.run("rm /.bkgColor")
  275. end
  276. end
  277. end
  278. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement