This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
PhilHibbs's profile picture

Melee Turtle mob farm script

Started by PhilHibbs, 29 January 2013 - 11:04 AM
PhilHibbs #1
Posted 29 January 2013 - 12:04 PM
Place "trash" item loot in first slot, e.g. Rotten Flesh for zombies, and this will be placed into the left chest. Everything else goes in the right chest.
http://pastebin.com/9fT8rnSi
Spoiler

-- ****************************************************************************
-- **																		**
-- **								FIGHT								   **
-- **																		**
-- **  Attacks in front													  **
-- **  Collects loot														 **
-- **  Drops loot that matches Slot 1 into the chest on the left			 **
-- **  Drops loot that does not match Slot 1 into the chest on the right	 **
-- **																		**
-- ****************************************************************************

while true do
  if turtle.getItemCount(16) > 0 then
	turtle.turnLeft()
	for n=2,16 do
	  turtle.select(n)
	  if turtle.compareTo(1) then
		turtle.drop()
	  end
	end
	turtle.select(1)
	turtle.drop(turtle.getItemCount(1)-1)
	turtle.turnLeft()
	turtle.turnLeft()
	for n=2,16 do
	  turtle.select(n)
	  if not turtle.compareTo(1) then
		turtle.drop()
	  end
	end
	turtle.select(1)
	turtle.turnLeft()
  end
  turtle.attack()  
  sleep(.1)
  turtle.suck()
  sleep(.1)
end
PLace turtle and chests like this:

Spoiler
unobtanium #2
Posted 29 January 2013 - 08:25 PM
Hello there,
this looks kinda cool. I will use this for some simple spawner setups.
However, i have some ideas which you can implement.
- What happens if one of the chests are full?
- you can use the first slot as storage too. Get the item count of this slot and drop this amount minus one.
- another version in which the turtle sort all items in different and more chests.
Just some little ideas to keep you updating this program :D/>
Mikeemoo #3
Posted 29 January 2013 - 08:44 PM
Good effort :)/> Maybe an improvement would be putting the chests above and below, that way you save time by not having to keep turning. You can just use dropUp and dropDown
PhilHibbs #4
Posted 29 January 2013 - 09:04 PM
The left and right chests are partly aesthetic, partly functional. The off switch for the spawned is under the turtle, and the block above is glass so I can see the zombies.
Frederikam #5
Posted 29 January 2013 - 09:09 PM
Don't think you need to use turtle.suck(), turtle.attack() does it.
PhilHibbs #6
Posted 29 January 2013 - 09:50 PM
I added the suck() because it was missing loot.
MrHohenheim #7
Posted 30 January 2013 - 10:06 AM
place near "brain in the jar" :)/> so cool collecting xp
xInDiGo #8
Posted 30 January 2013 - 01:24 PM
i used a similar script for my zombie farm, with a brain in a jar! :D/>
KykyRocks1 #9
Posted 02 June 2015 - 08:30 PM
I edited a little bit for use on a server. In case the server restarts/crashes while the turtle is facing the chest, I made it so that it will check to see which block matches whatever block you put in slot 16, then do a 180 (spins around so block matching slot 16 is in the back). Also, it empties the inventory when the item in slot 1 has more than 15 items (Since I'm using for a blaze farm) http://pastebin.com/myTqKyvF

Edited version which will only attack when it recieves a redstone signal from the back: http://pastebin.com/xdSdiW4z
Edited on 03 June 2015 - 10:56 PM