Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Printing tank fullness to nixie tubes")
- local prevTankPercent = -1 -- the tank doesn't seem to show up when no updates are given
- local blinkFlag = false
- while true do
- local tank = peripheral.find("modern_industrialization:large_tank_hatch")
- local display = peripheral.find("create_source")
- local percentage = -1
- local tanks = tank.tanks()
- if #tanks > 0 or tanks[1] ~= nil then
- local amount = tanks[1].amount
- local capacity = tanks[1].capacity
- local ratio = amount / capacity
- percentage = ratio *100
- print(tostring(os.time()).."new data")
- else
- print(tostring(os.time()) .. "outdated info")
- percentage = prevTankPercent
- end
- local outstr = ""
- if percentage == -1 then
- outstr = outstr .. " ??.??%"
- print(tostring(os.time()) .. "no data")
- elseif percentage == 1 then
- outstr = outstr .. "100.00%" .. " "
- else
- local dig_0 = math.floor((percentage / 10) % 10)
- local dig_1 = math.floor(percentage % 10)
- local dig_2 = math.floor((percentage *10) %10)
- local dig_3 = math.floor((percentage *100) %10)
- outstr = outstr .. " " .. tostring(dig_0) .. tostring(dig_1) .. "." .. tostring(dig_2) .. tostring(dig_3) .. "%" .. " "
- end
- if blinkFlag == true then
- if (percentage > prevTankPercent) then
- outstr = outstr .. "^"
- elseif (percentage < prevTankPercent) then
- outstr = outstr .. "v"
- else
- outstr = outstr .. " "
- end
- end
- display.clear()
- display.setCursorPos(1,1)
- display.write(outstr)
- prevTankPercent = percentage
- blinkFlag = not blinkFlag
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment