FoxWorn3365

LeNet

Dec 4th, 2021 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 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.lightBlue)
  87. term.setCursorPos((maxw - #testo) / 2, 1)
  88. term.setTextColor(colors.white)
  89. term.write(testo)
  90. end
  91.  
  92. function barraDiRicerca(testo)
  93. drawFilledBox(1, 2, maxw, 2, colors.lightGray)
  94. term.setCursorPos(10, 2)
  95. term.setTextColor(colors.black)
  96. term.write(testo)
  97. end
  98.  
  99. function alarm(testo, colore, y)
  100. drawFilledBox(1, y, maxw, y, colors[colore])
  101. term.setCursorPos((maxw - #testo) / 2, y)
  102. term.setTextColor(colors.white)
  103. term.write(testo)
  104. no()
  105. end
  106.  
  107.  
  108. function bottone(color, text, x, y)
  109. term.setBackgroundColor(colors[color])
  110. term.setTextColor(colors.white)
  111. term.setCursorPos(x, y)
  112. print(text)
  113. end
  114.  
  115. function drawA()
  116. term.setBackgroundColor(colors.white)
  117. term.setTextColor(colors.black)
  118. end
  119.  
  120. function ico(x, y, col, text)
  121. term.setBackgroundColor(colors[col])
  122. term.setTextColor(colors.white)
  123. term.setCursorPos(x, y)
  124. print(text)
  125. drawA()
  126. end
  127.  
  128. function loadPreferences()
  129. h = fs.open("/Hack/programmi/FoxNet/conf.public")
  130. confInit = h.readAll()
  131. h.close()
  132. return giremu(confInit, "$")
  133. end
  134.  
  135. function notFound()
  136. term.setTextColor(colors.red)
  137. print("ERRORE 404 - Pagina non trovata!")
  138. drawA()
  139. print("\n\nVerifica che:\n- L'url sia corretto\n- Il tuo PC sia connesso ad Internet")
  140. end
  141.  
  142. function getPage(url)
  143. page = http.get("http://172.16.20.220/luanet/"..url..".lua")
  144. if page == nil or page == '' then
  145. ntoFound()
  146. else
  147. pagina = loadstring(page.readAll())
  148. page.close()
  149. loadMenu()
  150. pagina()
  151. end
  152. end
  153.  
  154. function loadMenu()
  155. titolo("FoxNet - Un nuovo modo di navigare")
  156. ico(51, 1, "red", "X")
  157. drawA()
  158. barraDiRicerca("ln://")
  159. ico(1, 2, "green", "HOME")
  160. term.setBackgroundColor(colors.black)
  161. end
  162.  
  163.  
  164. deo = "homePage"
  165.  
  166.  
  167. while true do
  168. if deo == "homePage" then
  169. loadMenu()
  170. term.setCursorPos(15, 2)
  171. url = read()
  172. print("\n")
  173. getPage(url)
  174. event, key, x, y = os.pullEvent()
  175. end
  176. end
  177.  
Add Comment
Please, Sign In to add comment