Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- FoxInvest Holding
- ----------------------
- -- Titanus Elios
- -- Gestione del LATTE
- -----------------------
- maxw, maxh = term.getSize()
- local function drawPixelInternal(xPos, yPos)
- term.setCursorPos(xPos, yPos)
- term.write(" ")
- end
- local tColourLookup = {}
- for n = 1, 16 do
- tColourLookup[string.byte("0123456789abcdef", n, n)] = 2 ^ (n - 1)
- end
- function drawFilledBox(startX, startY, endX, endY, nColour)
- if type(startX) ~= "number" or type(startX) ~= "number" or type(endX) ~=
- "number" or type(endY) ~= "number" or
- (nColour ~= nil and type(nColour) ~= "number") then
- error("Expected startX, startY, endX, endY, colour", 2)
- end
- startX = math.floor(startX)
- startY = math.floor(startY)
- endX = math.floor(endX)
- endY = math.floor(endY)
- if nColour then term.setBackgroundColor(nColour) end
- if startX == endX and startY == endY then
- drawPixelInternal(startX, startY)
- return
- end
- local minX = math.min(startX, endX)
- if minX == startX then
- minY = startY
- maxX = endX
- maxY = endY
- else
- minY = endY
- maxX = startX
- maxY = startY
- end
- for x = minX, maxX do for y = minY, maxY do drawPixelInternal(x, y) end end
- end
- function clear()
- sfondo(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function clearRed()
- sfondo(colors.red)
- term.clear()
- term.setCursorPos(1, 1)
- end
- function titolo(testo)
- drawFilledBox(1, 1, maxw, 1, colors.white)
- term.setCursorPos((maxw - #testo) / 2, 1)
- term.setTextColor(colors.black)
- term.write(testo)
- no()
- end
- function bottone(color, text, x, y)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- term.setCursorPos(x, y)
- print(text)
- end
- function alarm(color, text)
- term.setBackgroundColor(colors[color])
- term.setTextColor(colors.white)
- print(" "..text.." ")
- no()
- end
- function getInput(id)
- rednet.send(id, "status")
- local rID, message = rednet.receive(2)
- return message
- end
- p = peripheral.wrap("back")
- var = 1
- while true do
- -- Recupero lo stato del tank
- local a, b, c, b1 = p.get(1)
- amount = b1.amount
- -- Stato
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.clear()
- titolo("Vendita di Carburanti")
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- if var == 1 then
- print("\nPer iniziare a vendere il carburante, premi il bottone!\n\nOvviamente prima di premere il bottone svuota interamente il carico dal treno!");
- bottone("blue", " VENDI ", 10, 10)
- -- Eventi
- local event, button, x, y = os.pullEvent("mouse_click")
- if y == 10 and x >= 10 and x <= 18 then
- var = 2
- end
- elseif var == 2 then
- -- 3811 -> Condensato | 21270 -> Gas metano | 163 -> Petrolio
- colo = {}
- names = {}
- price = {}
- colo[3811] = "lightBlue"
- colo[21270] = "pink"
- colo[163] = "gray"
- names[3811] = "Condensato"
- names[21270] = "Gas Metano"
- names[163] = "Petrolio"
- price[3811] = 1,2
- price[21270] = 0,8
- price[163] = 0,2
- tto = colo[b1.liquidId]
- term.setBackgroundColor(colors[tto])
- term.setTextColor(colors.white)
- print("\n" .. names[b1.liquidId])
- print("\n\nIC/litro: " .. price[b1.liquidId])
- print("\n\nQuantita': " .. b1.amount .. "/" .. b1.capacity)
- print("Paga totale: " .. b1.amount + price[b1.liquidId])
- end
- sleep(0,5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement