Advertisement
maxtorcd55

tank_infoo

Apr 5th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local p = peripheral.wrap("top")
  2.  
  3. while (true) do
  4.     local moni = nil
  5.     local linepos = 1
  6.     local t = p.getNamesRemote()
  7.     for mons = 1, #t do
  8.         if string.find(string.lower(t[mons]), "monitor") then
  9.             moni = peripheral.wrap(t[mons])
  10.         end
  11.     end
  12.     if moni == nil then
  13.         moni = peripheral.wrap("left")
  14.  
  15.     end
  16.     moni.clear()
  17.     moni.setCursorPos(1,1)
  18.  
  19.     for i = 1, #t do
  20.        
  21.         moni.setCursorPos(1,linepos)
  22.         if string.find(string.lower(t[i]), "tank") then
  23.             data = p.callRemote(t[i], "getTankInfo","")
  24.             if (data[1]["rawName"] ~= nil) and (data[1]["amount"] ~= nil) and (data[1]["capacity"] ~= nil) then
  25.                 moni.write(data[1]["rawName"]..": "..data[1]["amount"].."/"..data[1]["capacity"])
  26.                 linepos = linepos + 1
  27.             end
  28.            
  29.         end
  30.        
  31.     end
  32.     sleep(1)
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement