FoxWorn3365

Gestione Iron Tank

Mar 25th, 2022 (edited)
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- FoxInvest Holding
  2. ----------------------
  3. -- Titanus Elios
  4. -- Gestione del LATTE
  5. -----------------------
  6.  
  7.  
  8. maxw, maxh = term.getSize()
  9. local function drawPixelInternal(xPos, yPos)
  10.     term.setCursorPos(xPos, yPos)
  11.     term.write(" ")
  12. end
  13.  
  14. local tColourLookup = {}
  15. for n = 1, 16 do
  16.     tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
  17. end
  18.  
  19. function drawFilledBox(startX, startY, endX, endY, nColour)
  20.     if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
  21.         "number" or type(endY) ~= "number" or
  22.         (nColour ~= nil and type(nColour) ~= "number") then
  23.         error("Expected startX, startY, endX, endY, colour", 2)
  24.     end
  25.  
  26.     startX = math.floor(startX)
  27.     startY = math.floor(startY)
  28.     endX = math.floor(endX)
  29.     endY = math.floor(endY)
  30.  
  31.     if nColour then term.setBackgroundColor(nColour) end
  32.     if startX == endX and startY == endY then
  33.         drawPixelInternal(startX, startY)
  34.         return
  35.     end
  36.  
  37.     local minX = math.min(startX, endX)
  38.     if minX == startX then
  39.         minY = startY
  40.         maxX = endX
  41.         maxY = endY
  42.     else
  43.         minY = endY
  44.         maxX = startX
  45.         maxY = startY
  46.     end
  47.  
  48.     for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
  49. end
  50.  
  51. function clear()
  52.     sfondo(colors.black)
  53.     term.clear()
  54.     term.setCursorPos(1, 1)
  55. end
  56.  
  57. function clearRed()
  58.     sfondo(colors.red)
  59.     term.clear()
  60.     term.setCursorPos(1, 1)
  61. end
  62.  
  63. function titolo(testo)
  64.     drawFilledBox(1, 1, maxw, 1, colors.white)
  65.     term.setCursorPos((maxw - #testo) / 2, 1)
  66.     term.setTextColor(colors.black)
  67.     term.write(testo)
  68.     no()
  69. end
  70.  
  71. function bottone(color, text, x, y)
  72.    term.setBackgroundColor(colors[color])
  73.    term.setTextColor(colors.white)
  74.    term.setCursorPos(x, y)
  75.    print(text)
  76. end
  77.  
  78. function no()
  79.    term.setBackgroundColor(colors.black)
  80.    term.setTextColor(colors.white)
  81. end
  82.  
  83. function alarm(color, text)
  84.    term.setBackgroundColor(colors[color])
  85.    term.setTextColor(colors.white)
  86.    print(" "..text.." ")
  87.    no()
  88. end
  89.  
  90. function getInput(id)
  91.    rednet.send(id, "status")
  92.    local rID, message = rednet.receive(2)
  93.    return message
  94. end
  95.  
  96. p = peripheral.wrap("bottom")
  97.  
  98. while true do
  99.   -- Recupero lo stato del tank
  100.   local a, b, c, b1 = p.get(1)
  101.   amount = b1.amount
  102.   -- Stato
  103.   no()
  104.   term.clear()
  105.   no()
  106.   titolo("FIH - Latte - MNG e UPS")
  107.   OUTColor = "green"
  108. --  if getInput(1234) == "ON" then
  109. --     OUTColor = "green"
  110. --  else
  111. --     OUTColor = "red"
  112. --  end
  113.   if cicalino == true then
  114.     rs.setOutput("right", true)
  115.   else
  116.     rs.setOutput("right", false)
  117.   end
  118.   print("\n\nOUT MAN:")
  119.   term.setCursorPos(10, 3)
  120.   term.setBackgroundColor(colors[OUTColor])
  121.   term.write("  ")
  122.   no()
  123.   print("\nOUT AUTO:")
  124.   term.setCursorPos(10, 4)
  125.   term.setBackgroundColor(colors[OUTColor])
  126.   term.write("  ")
  127.   no()
  128.   print("\nIN AUTO:")
  129.   term.setCursorPos(10, 5)
  130.   term.setBackgroundColor(colors[OUTColor])
  131.   term.write("  ")
  132.   no()
  133.   print("\nIN MAN:")
  134.   term.setCursorPos(10, 6)
  135.   term.setBackgroundColor(colors[OUTColor])
  136.   term.write("  ")
  137.   no()
  138.   print("\n\nMAX Q:")
  139.   term.setCursorPos(10, 8)
  140.   term.setTextColor(colors[OUTColor])
  141.   term.write(tostring(b1.capacity))
  142.   no()
  143.   print("\nLIQUID:")
  144.   term.setCursorPos(10, 9)
  145.   term.setTextColor(colors[OUTColor])
  146.   term.write("Milk (latte) - ID: "..b1.liquidId)
  147.   no()
  148.   print("\nAMOUNT:")
  149.   term.setCursorPos(10, 10)
  150.   term.setTextColor(colors[OUTColor])
  151.   term.write("Milk (latte) - ID: "..amount)
  152.   no()
  153.   if amount < 1000000 then
  154.     UPSColor = "orange"
  155.     cicalino = true
  156.     rs.setOutput("back", true)
  157.   else
  158.     UPSColor = "red"
  159.     cicalino = false
  160.     rs.setOutput("back", false)
  161.   end
  162.   print("\n\nUPS:")
  163.   term.setCursorPos(10, 12)
  164.   term.setBackgroundColor(colors[UPSColor])
  165.   term.write("  ")
  166.   no()
  167. sleep(0.2)
  168. end
  169.  
  170.  
Add Comment
Please, Sign In to add comment