crameep

BoilerControls

Apr 6th, 2013
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. os.loadAPI("ocs/apis/sensor")
  2. os.loadAPI("ocs/apis/graph")
  3. local prox = sensor.wrap("left")
  4. local i = 0
  5. local targets = prox.getTargets()
  6.  
  7. for name,basicDetails in pairs(targets) do
  8.   print("Found Tank: "..name)
  9.   tankDetails = prox.getTargetDetails(name)
  10.   if (tankDetails ~= nil) then
  11.     tank = name
  12.     break
  13.   end
  14. end
  15.  
  16. if type == "item.fuel" then
  17.  type = "Fuel"
  18. end
  19.  
  20. function update()
  21.   i = i + 1
  22.   local amt = sensor.call("left", "getTargetDetails",tank)
  23.   if amt ~= nil then
  24.   amount = amt.Tanks[1].Amount
  25.   capacity = amt.Tanks[1].Capacity
  26.   if amount < (capacity / 2) then
  27.     redstone.setOutput("right",false)
  28.   end
  29.   return amount
  30.   else
  31.   print("amt was null")
  32.   end
  33. end
  34.  
  35. function newLine()
  36.   local_,cY= mon.getCursorPos()
  37.   mon.setCursorPos(1,cY+1)
  38. end
  39.  
  40. mon = peripheral.wrap("top")
  41. graphInstance = graph.new(mon, update, type, nil, 0 , capacity)
  42. mon.setTextScale(5)
  43. while true do
  44.  
  45. graphInstance:draw()
  46. newLine()
  47. mon.write(" Consuming: ")
  48. mon.setTextColor(colors.lightBlue)
  49. mon.write(fuelcons)
  50. mon.setTextColor(colors.white)
  51. mon.write(" /h")
  52. newLine()
  53. mon.write(" Time Remaining: ")
  54. mon.setTextColor(colors.yellow)
  55. mon.write(timeleft)
  56. mon.setTextColor(colors.white)
  57. mon.write(" Hours")
  58. sleep(5)
  59. end
Advertisement
Add Comment
Please, Sign In to add comment