Advertisement
Guest User

basdim

a guest
Nov 23rd, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.89 KB | None | 0 0
  1. function hasTeleFocus()
  2.     return turtle.getItemCount(1) ~= 0
  3. end
  4.  
  5. function acceptItems(accept)
  6.     redstone.setOutput("left", not accept)
  7. end
  8.  
  9. function isSource()
  10.     return redstone.getInput("back")
  11. end
  12.  
  13. function getOtherFocus()
  14.     acceptItems(false)
  15.     turtle.dropDown()
  16.  print("Pushing item to chest")
  17.     -- Source should allow target some time to
  18.     -- fetch other focus. 3s should be enough.
  19.     if isSource() then
  20.   print("Waiting for target")
  21.         os.sleep(3)
  22.  end
  23.  
  24.     while not turtle.suckDown() do
  25.         os.sleep(1)
  26.  end
  27.  print("Got other focus")
  28.  
  29.     turtle.dropUp()
  30.     acceptItems(true)
  31. end
  32.  
  33. function triggerTeleport()
  34.  print("Triggering teleport")
  35.     redstone.setOutput("top", true)
  36.     os.sleep(1)
  37.     redstone.setOutput("top", false)
  38. end
  39.  
  40. while true do
  41.     if hasTeleFocus() then
  42.   print("Have foci")
  43.         getOtherFocus()
  44.  
  45.     if isSource() then
  46.         triggerTeleport()
  47.   end
  48.  end
  49.  os.sleep(1)
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement