Advertisement
ThSchm

PumpControl

Feb 10th, 2015
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.61 KB | None | 0 0
  1. local tank = peripheral.wrap("back")
  2. local info
  3. local amount
  4. local capacity
  5. local percentage
  6. local outputRedstone
  7.  
  8. while true do
  9.   info = tank.getTankInfo("unknown")
  10.     for k,v in pairs(info) do
  11.     for x, y in pairs(v) do
  12.       if x == "amount" then
  13.         amount = y
  14.       end
  15.       if x == "capacity" then
  16.         capacity = y
  17.       end
  18.     end
  19.   end
  20.  
  21.   percentage = amount / capacity
  22.  
  23.   outputRedstone = (percentage >= 0.25)
  24.  
  25.   redstone.setOutput("bottom", outputRedstone)
  26.  
  27.   print("Percentage: "..percentage..", output: "..tostring(outputRedstone)..", time: "..os.time())
  28.  
  29.   sleep(2)
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement