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

Crafty [] Autocrafty [] Autopattern

Started by Ellie0815, 07 September 2012 - 03:42 PM
Ellie0815 #1
Posted 07 September 2012 - 05:42 PM
OH sweet Crafty got some babies!


Hey there

I just built a small program which lets you use a crafting turtle over the keyboard.
Put the ingredients (up to 6 stacks) in front of Crafty and start the program.

1..6 to select inventory slots

qwe
asd —-for the crafting grid
xcv

Space to craft
and k to abort


Im sure this kind of program already exists but I built this as a part of my "AI Challenge" (more on that maybe later)
Its not fool proof at all and the os.exit() throws a nil error but it does its job and aborts the program :D/>/>
This might be updated/improved or not in the future as it is only a snippet of another "project"

suggestions and help very appreciated as Im a Lua noob

http://pastebin.com/Lnq6gM0B

Edit: a bit more fool proof now. Items that are replaced in the crafting grid now go back to the inventory slots instead to the buffer slot 13


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Crafty can now craft things on its own!! Well.. kind of.. you still need to feed..

Also Crafty can now make Patterns.

Autopattern is a program to make Patterns Autocrafty can use.
autopattern <filename> to start writing a pattern in Crafty
Space to save Pattern

http://pastebin.com/rbNX8xLt


The Patterns are used by Autocrafty
autocrafty <filename> to start autocrafting from Pattern

http://pastebin.com/cmhkz3Av


maybe I will merge them to one sometime as they are only slightly modified versions.
Cranium #2
Posted 07 September 2012 - 05:45 PM
os.exit() does not exist. Perhaps you are thinking of os.shutdown() or os.reboot()?
There is also a command to break out of a look. Just put break at the part you want to exit the loop.
GopherAtl #3
Posted 07 September 2012 - 05:50 PM
Pretty clever handling, tho I'd get confused with the relabled slot numbers - why not just use 1-16?

And instead of "os.exit()" just do "return" to exit the program :D/>/>

edit: note this won't work from inside a function, since it'll just exit the function! But it'll work where you call os.exit()
Ellie0815 #4
Posted 07 September 2012 - 05:55 PM
Pretty clever handling, tho I'd get confused with the relabled slot numbers - why not just use 1-16?

And instead of "os.exit()" just do "return" to exit the program :D/>/>

edit: note this won't work from inside a function, since it'll just exit the function! But it'll work where you call os.exit()

because the crafting grid of the crafting turtle is the standard 3x3 starting on the upper left slot 1 and the turtle has a 4x4 grid so slots which should be 1..9 are 1..3 5..7 9..11

CCCX
CCCX
CCCX
XXXX

Thank you for the return tip. I have only used it for returning values in objects and classes before.
Fixed that.
GopherAtl #5
Posted 07 September 2012 - 06:00 PM
yeah, I see the logic of your way, just saying, I already think of the slots as 1-16 so it's strange thinking of slot 4 as 1, slot 8 as 2, etc :D/>/>