Advertisement
FoxWorn3365

Vendita

Jun 24th, 2022 (edited)
1,096
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.53 KB | None | 0 0
  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 alarm(color, text)
  79.    term.setBackgroundColor(colors[color])
  80.    term.setTextColor(colors.white)
  81.    print(" "..text.." ")
  82.    no()
  83. end
  84.  
  85. function getInput(id)
  86.    rednet.send(id, "status")
  87.    local rID, message = rednet.receive(2)
  88.    return message
  89. end
  90.  
  91. p = peripheral.wrap("back")
  92.  
  93. var = 1
  94. while true do
  95.   -- Recupero lo stato del tank
  96.   local a, b, c, b1 = p.get(1)
  97.   amount = b1.amount
  98.   -- Stato
  99.    term.setBackgroundColor(colors.black)
  100.    term.setTextColor(colors.white)
  101.    term.clear()
  102.    titolo("Vendita di Carburanti")
  103.    term.setBackgroundColor(colors.black)
  104.    term.setTextColor(colors.white)
  105.   if var == 1 then
  106.     print("\nPer iniziare a vendere il carburante, premi il bottone!\n\nOvviamente prima di premere il bottone svuota interamente il carico dal treno!");
  107.     bottone("blue", " VENDI ", 10, 10)
  108.     -- Eventi
  109.     local event, button, x, y = os.pullEvent("mouse_click")
  110.     if y == 10 and x >= 10 and x <= 18 then
  111.       var = 2
  112.     end
  113.   elseif var == 2 then
  114.     -- 3811 -> Condensato | 21270 -> Gas metano | 163 -> Petrolio
  115.     colo = {}
  116.     names = {}
  117.     price = {}
  118.     colo[3811] = "lightBlue"
  119.     colo[21270] = "pink"
  120.     colo[163] = "gray"
  121.     names[3811] = "Condensato"
  122.     names[21270] = "Gas Metano"
  123.     names[163] = "Petrolio"
  124.     price[3811] = 1,2
  125.     price[21270] = 0,8
  126.     price[163] = 0,2
  127.     tto = colo[b1.liquidId]
  128.    term.setBackgroundColor(colors[tto])
  129.    term.setTextColor(colors.white)
  130.     print("\n" .. names[b1.liquidId])
  131.     print("\n\nIC/litro: " .. price[b1.liquidId])
  132.     print("\n\nQuantita': " .. b1.amount .. "/" .. b1.capacity)
  133.     print("Paga totale: " .. b1.amount + price[b1.liquidId])
  134.   end
  135.   sleep(0,5)
  136. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement