Advertisement
RLPGhost

Lua Tank Detection

Sep 8th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local tank = peripheral.wrap("back")
  2.  
  3. local amount            
  4.  
  5. function getTank(tankPeriph)
  6.     local tableInfo = tankPeriph.getTankInfo()
  7.  
  8.     fluidRaw = nil
  9.     fluidName = nil
  10.     fluidAmount = nil
  11.     fluidCapacity = nil
  12.      
  13.     for k,v in pairs(tableInfo) do
  14.       fluidCapacity = v.capacity
  15.  
  16.       if v.contents then
  17.         for i,w in pairs(v.contents) do
  18.           if i == "rawName" then
  19.             fluidRaw = w
  20.           elseif i == "amount" then
  21.             fluidAmount = w
  22.           elseif i == "name" then
  23.             fluidName = w
  24.           end
  25.         end
  26.       end
  27.     end
  28.  
  29.     return fluidRaw, fluidName, fluidAmount, fluidCapacity
  30. end
  31.  
  32. --// Programme de control du tank
  33.  
  34. while true do
  35.  
  36. redstone.setOutput("front", false)
  37. local fluidRaw, fluidName, fluidAmount, fluidCapacity = getTank(tank)
  38.  
  39. if fluidName then
  40.     redstone.setOutput("front", true)
  41. end
  42. sleep (1)
  43.  
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement