Advertisement
Clorith

LiquidScan

Apr 13th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.88 KB | None | 0 0
  1. -- Configuration
  2. local rednetLocation = "top"
  3. local drumLocation   = "back"
  4. local numeric        = 1
  5. local liquid       = {}
  6. -- Configuration End
  7.  
  8. drum = peripheral.wrap( drumLocation )
  9.  
  10. rednet.open( rednetLocation )
  11.  
  12. while true do
  13.     local drumdata     = drum.getTankInfo()[1]
  14.  
  15.     local maxValue     = drumdata["capacity"]
  16.  
  17.     if not nil == drumdata["contents"] then
  18.         local id           = drumdata["contents"]["name"]
  19.         local currentValue = drumdata["contents"]["amount"]
  20.         local label        = drumdata["contents"]["rawName"]
  21.  
  22.         if nil == liquid then
  23.             liquid["id"]    = id
  24.             liquid["label"] = label
  25.         end
  26.     else
  27.         local currentValue = 0
  28.     end
  29.  
  30.     if not nil == liquid then
  31.         rednet.broadcast( "liquidData " .. numeric .. " " .. liquid["id"] .. " " .. currentValue .. " " .. maxValue .. " " .. liquid["label"] .. "" )
  32.     end
  33.  
  34.     sleep( 10 )
  35. end
  36.  
  37. rednet.close( rednetLocation )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement