SHARE
TWEET

ComputerCraft Tutorial: auto_melee_trap0_2

hevohevo Feb 8th, 2014 306 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- #################################
  2. -- auto_melee_trap
  3. -- version 0.2
  4. -- http://hevohevo.hatenablog.com/
  5. -- The turtle suspends the operation during the redstone ON.
  6.  
  7. -- ################ config
  8. RSSide = "back"
  9.  
  10.  
  11. -- ################ functions
  12. -- When the inventory was filled to capacity, drop all items.
  13. function dropItems()
  14.   if turtle.getItemCount(16) >0 then
  15.     for i=1,16 do
  16.       turtle.select(i)
  17.       turtle.dropDown()
  18.     end
  19.     turtle.select(1)
  20.   end
  21. end
  22.  
  23. -- ################ main
  24.  
  25. turtle.select(1)
  26.  
  27. while true do
  28.   if not rs.getInput(RSSide) then --redstone ON
  29.     turtle.attack()
  30.     turtle.suck()
  31.     dropItems()
  32.   else -- redstone ON
  33.     -- wait for the inputted signal to change OFF
  34.     print("suspend")
  35.     os.pullEvent("redstone")
  36.     print("attack")
  37.   end
  38. end
RAW Paste Data
Top