Jump to content




Automatic Sheep Shearing

turtle

  • You cannot reply to this topic
13 replies to this topic

#1 DavEdward

  • Members
  • 17 posts

Posted 03 January 2013 - 07:41 AM

I'm still a bit new to LUA but after a number of attempts I successfully made a simple Sheep Shearing program to automate getting wool.

*This program requires a Shearing turtle from MiscPeripherals 2.3 or higher!*

There is one bug with this program which is that I tried to add a code to the program to have the turtle detect if the chest it was trying to put wool into was full it would stop working and wait for there to be space in the chest. However this code kept throwing an error that I didn't know how to correct so I commented out that peice of the code.

As long as you make sure the chest doesn't get over-filled, the program works great. If someone feels up to debugging that problem in my code please share!

For the setup, it's best to have two shearing turtles in a 5x3 or 6x3 space set up n a way that there is only 1 block between the turtles and walls keeping the sheep in such as below.

T = Turtle
S = Space

S S S S S
S T S T S
S S S S S
  or
S S S S S S
S T S S T S
S S S S S S

Here's the code:
Spoiler


Set up a coal chest above the turtles, and a storage chest below both turtles. The coal chests are optional. To my own experiance feeding a turtle a stack of charoal is enough to have it run for so long I filled a double-chest with wool.

If you have BuildCraft, Redpower, or similar, you may want to pull items out of the chests under the turtles and pipe it elsewhere. If desired it's easy enough to flip the code so the turtle puts items in the chest above them, and either tries to fetch coal from below, or just fill them yourself.


Edits:

Edit 1,2,3: Removed garbage code I forgot was in there during testing, fixed indentation some to reduce confusion.
Edit 4: Changed the line "storecheck = turtle.dropDown()" to "storecheck = not turtle.dropDown()" to see if that works. Left code commented out till i can test it.

#2 unobtanium

  • Members
  • 505 posts

Posted 03 January 2013 - 07:55 AM

Hello there,

i looked over your code and your bug with the "store into chest" part.
First you have one more "end" then you need. I added some notations behind the "ends".
Spoiler

Now to your bug:
storecheck = turtle.dropDown()
This gives true back if they Turtle could place the whole stack into the chest. If the chest is full, it returns false.
At the beginning you ask in the while loop, if storecheck is false. If the first stack in slot 1 is sucessfully taken out, it stops the while loop and never take out slot 2-15. edit: It never ends the while loop if the wool successfully drop it into the chest, i think :/
And it will go into the else section and start saying that it needs more space in the chests :D

I hope i solved it. Change end to else and storecheck = turtle.dropDown() to storecheck = not turtle.dropDown()
And you dont need a while loop accually :D Put the while-else part into the for loop. I hope this make sense :P

UNOBTANIUM

#3 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 03 January 2013 - 08:02 AM

I'm pretty sure that shears can be used by regular turtles, can't they?

#4 Draco18s

  • New Members
  • 1 posts

Posted 03 January 2013 - 08:39 AM

View PostUNOBTANIUM, on 03 January 2013 - 07:55 AM, said:

Hello there,

i looked over your code and your bug with the "store into chest" part.
First you have one more "end" then you need. I added some notations behind the "ends".
Spoiler


You missed a for() loop.

Spoiler


#5 DavEdward

  • Members
  • 17 posts

Posted 03 January 2013 - 09:01 AM

View PostUNOBTANIUM, on 03 January 2013 - 07:55 AM, said:

Hello there,

i looked over your code and your bug with the "store into chest" part.
First you have one more "end" then you need. I added some notations behind the "ends".
Spoiler

Now to your bug:
storecheck = turtle.dropDown()
This gives true back if they Turtle could place the whole stack into the chest. If the chest is full, it returns false.
At the beginning you ask in the while loop, if storecheck is false. If the first stack in slot 1 is sucessfully taken out, it stops the while loop and never take out slot 2-15. edit: It never ends the while loop if the wool successfully drop it into the chest, i think :/
And it will go into the else section and start saying that it needs more space in the chests :D

I hope i solved it. Change end to else and storecheck = turtle.dropDown() to storecheck = not turtle.dropDown()
And you dont need a while loop accually :D Put the while-else part into the for loop. I hope this make sense :P

UNOBTANIUM

As Draco18s pointed out there was a sneaky if statement in there for that extra end. However when I can test things I'll try swapping that storecheck to a "not turtle.dropDown()" instead.

#6 DavEdward

  • Members
  • 17 posts

Posted 03 January 2013 - 09:02 AM

View PostCranium, on 03 January 2013 - 08:02 AM, said:

I'm pretty sure that shears can be used by regular turtles, can't they?

Not to my knowledge. I have MiscPeripherals installed and one of it's featues is making a shearing turtle. I don't think CC can do it without that additional mod.

#7 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 04 January 2013 - 03:41 AM

Sheers can be used by regular turtle, yes.

However, they of course start to break after a while which adds a bit of complication.

#8 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 04 January 2013 - 03:54 AM

View PostMikeemoo, on 04 January 2013 - 03:41 AM, said:

Sheers can be used by regular turtle, yes.

However, they of course start to break after a while which adds a bit of complication.
uhh, i dont see them here: http://computercraft.info/wiki/Turtle
and i dont see durablility anywhere

#9 Mikeemoo

  • Members
  • 732 posts
  • LocationLondon, UK

Posted 04 January 2013 - 03:58 AM

View PostPixelToast, on 04 January 2013 - 03:54 AM, said:

View PostMikeemoo, on 04 January 2013 - 03:41 AM, said:

Sheers can be used by regular turtle, yes.

However, they of course start to break after a while which adds a bit of complication.
uhh, i dont see them here: http://computercraft.info/wiki/Turtle
and i dont see durablility anywhere

turtle.place() will use them if they're in the inventory.

#10 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 04 January 2013 - 03:59 AM

*facepalm*
i fail

#11 unobtanium

  • Members
  • 505 posts

Posted 06 January 2013 - 02:24 AM

Wops. I failed too :D

#12 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 06 January 2013 - 06:14 AM

i saw a sheep farm on geevancraft but it used block breakers i think
it was also on fire

#13 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 08 January 2013 - 05:54 AM

No, it was using deployers.

#14 leftler

  • Members
  • 11 posts

Posted 01 March 2013 - 06:05 PM

Here is a bit better placement pattern, this gives you all 16 colors gaurteneed with 4 turtles, the nice thing about this design is you don't need to wait for the sheep to be in the right place at the right time to be sheered.. You have to put a block above the turtles so the sheep don't jump on top of them and move out of their assigned slots, if you are not using some kind of pipe system (build craft, red power 2, ect) to empty the chests you could put the chests on top of the turtles and use them has the blocking blocks so you could reach them and empty the chests by hand.

Posted Image

Also, you can remove your fuel code, turning does not cost fuel, only forward, back, up and down does





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users