2 posts
Posted 26 March 2013 - 01:02 AM
I would like to automate my enchanting process but I'm pretty terrible at writing my own code and I haven't found a program that suits my need.
Currently I have my xp turtle right in from of a brain in a jar and have cobbled together some pretty terrible code that I can run when ever the brain gets 30 levels and it'll enchant a book.
table = peripheral.wrap("right")
table.get()
turtle.select(16)
table.enchant(30)
What I would like is a program that constantly gets xp from the brain and enchants when it reaches 30 levels. I would then like it to put the enchanted book in a chest directly above it and possibly retrieve new books from the same chest. (It'd probably be an ender chest with golems taking out the enchanted books and maintaining a supply of regular books)
I tried doing some of this myself but I can't think of a way to keep getting the xp and then enchanting and I couldn't get it to work if there was more than one book in the stack.
Any help would be greatly appreciated.
65 posts
Posted 13 April 2013 - 04:47 AM
Check the peripheral documentation. I think it would be table.absorb() or table.get() to absorb XP. If you want to have it enchant multiple books, you'd likely have to have the turtle transfer one book to the enchanting slot at a time once his XP got to 30, enchant it, and store it in a chest. The one I have setup kills monsters, aborbs the XP, and anything that goes in slot 16 will automatically try to enchant it at level 30. He is seeing the entire stack as one item and trying to enchant the stack, not one book. Since that is not possible, your function will return false.
I think the correct function for moving items within the turtle is turtle.transferTo(slotnumber). I'd have a second look at the APIs just to be sure. I'm not able to access them where I am.
11 posts
Posted 24 June 2013 - 02:38 PM
- setAutoCollect(autoCollect): If autoCollect is true, allow the turtle to automatically collect XP periodically.
- enchant(levels): Enchants the item in the current slot using the specified levels. Returns true if successful, false if not.
If you look at the avaible functions (there're more but we dont really need them) you will see that a turtle can also do the same work as brain in a jar (collect XP automatically).
local enchantWithLevel = 30
local suckBook = "suckUp"
local dropBook = "dropUp"
turtle.select(1) --select first slot on start
local enchant = peripheral.wrap("right")
enchant.setAutoCollect(true) --autocollect XP
while true do
if enchant.getLevels()>=enchantWithLevel then
if turtle[ suckBook ] then
if enchant.enchant( enchantWithLevel ) then
--successfully enchanted
turtle[ dropBook ]
else
print("Something went wrong")
break -- abort the programm to see what happened
end
end
end
sleep(30)
end
That code should work. You also can set input/output sides for books/enchanted books.
By the way, DO NOT WRAP peripherals to
table ok? Although you don't use it here, it's a bad idea.
// I'm going to finish the code (surely till saturday) with an attacking+enchanting turtle, much better than dw20's turtles.
1 posts
Posted 02 September 2013 - 07:07 AM
Is it a bug because I get athorpods 4 books all the time? (My set up is where the turtle kills skellys from a spawner, after they take about 17 points of damage) my code (self written)
http://pastebin.com/dC8QsXuu
3 posts
Posted 21 September 2013 - 08:12 PM
Hello, i written a little Programm for my little EP Farm where my turtle fights skeletons and cleans its inventory, then if the turtle is lvl 30 it grabs a book from the chest above him and enchants it. After that it puts the enchanted book in a chest under the turtle and starts from new.
LINK:
http://pastebin.com/WxiDTWsbI only have a problem that my XP Turtle dont want to enchant books (it just end the Program and stops doing anything.) If someone can help me with that little Problem, that would be nice. Else the Programs runs pretty well and i dont have any other Problems with that. The Mobsrops will droped in a chest to the side and will pumped out to an Void Pipe (cause i have allready enought bows and Arrow to bild my own little Army).
Im from Germany so dont judge my English. Its maybe not the best.
Greetings
Etone
8543 posts
Posted 21 September 2013 - 08:48 PM
Moved to Ask a Pro.
2 posts
Posted 27 September 2013 - 12:17 AM
Where is the download link to the enchanting turtles for 1.4.7?