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

Crafty Turtle complete crafting utility.

Started by apottere, 02 March 2013 - 07:49 PM
apottere #1
Posted 02 March 2013 - 08:49 PM
Here's my turtle crafting utility: http://pastebin.com/C3HeFxgE. Pastebin messed up the tabbing a little, but all the content is there.

Example turtle program for crafting compost from wheat and dirt using Crafty:

Setup: Redstone input on the front, so it knows where to start in case of a server restart, wheat in a box below, dirt in a box above, output chest to the right.

Code:

dofile("/Crafty.lua")
c = Crafty:new( nil, "bottom", nil,
			 "bottom", "top", "bottom",
			 nil, "bottom", nil,
			 "right", 2)
c:run()

The constructor takes nine sides, one for each area of the crafting table, and another for output and a wait length in case things get backed up. The first nine are the location of the boxes that have that material, broken up to represent the crafting table.

Features:
  • Automatically blocks when an input box is empty or the output box is full, without crashing (and a variable wait time to try again)
  • Automatic error detection, if a craft() fails it will hang and wait for the user to kill it or tell it to continue.
  • Because it needs some way to tell which side is the front, you need to give it redstone input on the front. Eventually I'll be adding (possibly) the ability to tell it which side the redstone is on, but not now. If you use an OR Gate on a structure pipe set to no redstone -> redstone, it will blink when an error occurs.
  • Automatic stack splitting of the same type if input box for that type is empty.
  • Detects closest path for turning to required box (only saves a turn now and again, but it was fun to make)
  • Due to the stationary nature of the turtles, it can only craft recipes with up to 4 different items (6 sides - 1 redstone - 1 output), but this may be upgraded to 5 in the future.
Let me know if you guys have anything else you'd like to see added!
Bubba #2
Posted 03 March 2013 - 06:38 AM
Did you mean to post this in the programs section? I don't see a question here :)/> Just report it if you need it moved.

As for the program, it looks like you put a fair bit of work into this. Good job!
apottere #3
Posted 03 March 2013 - 07:52 AM
Yeah… I was new so I requested it to be moved to a topic, but I'll report it to the right section. Thanks for noticing!
Lyqyd #4
Posted 03 March 2013 - 08:39 AM
Moved to Turtle Programs.