--[[
	Simple status display for Railcraft boiler with a Liquid fuelbox.
	by got_m1lk
--]]

--Specify side of wired modem
-- Valid: "left", "right", "front", "back", "top", "bottom"
local modemside = "left"

--Specify side of monitor
--If the monitor is attached to the modem specify peripheral name instead.
local monitor = "top"

--Specify the ID of the attached Railcraft liquid fueled firebox
local boiler = "liquid_fueled_boiler_firebox_0"



local net = peripheral.wrap(modemside)
local mon = peripheral.wrap(monitor)
local b = peripheral.wrap(boiler)

mon.clear()
--Adjust the textscale if you have a bigger/smaller monitor
--Increments of 0.5
mon.setTextScale(1)
mon.setTextColor(512)
mon.setCursorPos(1,1)
mon.write("Boiler status:")
  
while true do

tank = b.getTanks("top")


    

  local i = 3
  
  for k,v in pairs(tank)do
  
	  mon.setCursorPos(1,i)
	  mon.clearLine()
	  mon.setTextColor(512)
	  
	  if v["name"] ~=nil then
		mon.write(v["name"] .. ": ")
      end
	  
	  mon.setTextColor(colors.orange)
	  if v["amount"] ~=nil and v["capacity"] ~=nil then
	      mon.setCursorPos(9,i)
		  tmp = (v["amount"] / v["capacity"]) *100
		  tmp = string.match(tostring(tmp),"[^%.]+")
		  mon.write(tmp .. "%")
	  end
	  i = i +1
  end
  
  
  mon.setCursorPos(1,i)
  mon.clearLine()
  mon.setTextColor(512)
  temp = string.match(tostring(b.getTemperature()),"[^%.]+")
  mon.write("Temp:   ")
  mon.setTextColor(colors.orange)
  mon.write( temp .."'C") 
  os.sleep(1)
end