Guest User

Untitled

a guest
Dec 9th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. local inv = sensor.wrap("top")
  3. rednet.open("back")
  4.  
  5. function loadTable()
  6.   file = fs.open("invLocs.txt", "r")
  7.   invIDs = { }
  8.   if file then
  9.     for line in file.readLine do
  10.         local ID, loc = string.match(line, "(%w+)%s=%s(%S+)")
  11.         invIDs[ID] = loc
  12.     end
  13.   end
  14.   file.close()
  15. end
  16.  
  17. function getCount(tabID)
  18.   print(tabID)
  19.   foo = tostring(tabID)
  20.   tabInv = inv.getTargets()[foo]
  21.   invCount = tabInv["ItemCount"]
  22.   return invCount
  23. end
  24.  
  25. function sendBones()
  26.   boneCount = getCount(invIDs["inv01"])
  27.   rednet.send(25, boneCount)
  28. end
  29.  
  30. loadTable()
  31. while true do
  32.   sendBones()
  33.   print("Bones = " .. boneCount)
  34.   sleep(5)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment