Shaka01

lootcount sender

Oct 19th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. rednet.open("right")
  2. items = { }
  3. input= "back"
  4. output= "bottom"
  5. receiver = 3
  6.  
  7.  
  8. function clearscreen()
  9.     term.clear()
  10.     term.setCursorPos(1, 1)
  11. end
  12.  
  13. function suckItems()
  14.     turtle.select(1)
  15.     redstone.setOutput(output, false)
  16.     redstone.setOutput(input, true)
  17.     repeat
  18.         sleep(1)
  19.     until turtle.getItemCount(16) > 0
  20.     redstone.setOutput(input, false)
  21. end
  22.  
  23. function emptyInv()
  24.     redstone.setOutput(output, true)
  25.     repeat
  26.     sleep(0.5)
  27.     totalinv = 0
  28.         for i=1, 16 do
  29.             totalinv = totalinv + turtle.getItemCount(i)
  30.         end
  31.     until totalinv == 0
  32. end
  33.  
  34. function countItems()
  35.     for i=1, 16 do
  36.         if turtle.getItemCount(i) > 0 then
  37.             data = turtle.getItemDetail(i)
  38.             msg = table.concat({data.name, data.count,data.damage}, " ")
  39.             rednet.send(receiver, msg)
  40.             --print(msg)
  41.         end
  42.     end
  43. end
  44.  
  45.  
  46.    
  47.        
  48. function doit()
  49.     while true do
  50.         suckItems()
  51.         countItems()
  52.         emptyInv()
  53.         sleep(0.5)
  54.     end
  55. end
  56.  
  57. doit()
Add Comment
Please, Sign In to add comment