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

Enchant-o-matic

Started by yarma92, 16 March 2013 - 06:56 AM
yarma92 #1
Posted 16 March 2013 - 07:56 AM
Hi guys, this is my first published piece of code, it requires misc. peripherals to work though.


Its a simple set up really, the turtle dumps enchanted books into the chest at the (or on the right if you want it to) and pulls books 1 at a time from the chest above and produces level 30 enchantments.

Here is the code, and the pastebin http://pastebin.com/P7qXS1sS
Spoiler

   

m=peripheral.wrap("right")
m.setAutoCollect(true)

function levelCheck()
 level = m.getLevels()
 shell.run("clear")
 print ("Currently level: "..level)
 return level
end

function getBook()
 local bookCount
 local toReturn
 turtle.suckUp()
 bookCount = turtle.getItemCount(1)
 if bookCount == 0 then
  while bookCount == 0 do
   shell.run("clear")
   print ("Please Reload the Chest")
   sleep(1)
   turtle.suckUp()
   bookCount = turtle.getItemCount(1)
  end
 end
 if bookCount ~= 0 then do
  print("Returning Books")
  sleep(2)
  returnBooks(bookCount)
  print("Extra books returned")
 end
 end
end

function returnBooks(x)
 x = x-1
 print("Returning "..x.." books")
 sleep(4)
 turtle.transferTo(2, x)
 turtle.select(2)
 turtle.dropUp()
 turtle.select(1)
end


while true do
 local lv = levelCheck()

 if lv >= 30 then
  getBook()
  m.enchant(30)
  turtle.drop()
 end
 sleep (2)
end

Please comment with feedback and suggestions/improvements.

Edit: New version is up.
Change Log
Spoiler16/03/12 - Fixed a bug where it would not replace books correctly when reloading the top chest.

Yarma
SyberSmoke #2
Posted 17 April 2013 - 05:37 PM
I was wondering if you could add a kill mob command also. The idea behind this is just having a sword on one side, enchant table peripheral on the other and the mobs are funneled to the turtle. The turtle kills some mobs collects the XP, enchants a book once in awhile, and it is a nice neat one turtle package.
improvshark #3
Posted 19 May 2013 - 04:29 PM
I was wondering if you could add a kill mob command also. The idea behind this is just having a sword on one side, enchant table peripheral on the other and the mobs are funneled to the turtle. The turtle kills some mobs collects the XP, enchants a book once in awhile, and it is a nice neat one turtle package.

I have made a program very similar to this one and it does just that
SyberSmoke #4
Posted 21 May 2013 - 10:31 PM
I was wondering if you could add a kill mob command also. The idea behind this is just having a sword on one side, enchant table peripheral on the other and the mobs are funneled to the turtle. The turtle kills some mobs collects the XP, enchants a book once in awhile, and it is a nice neat one turtle package.

I have made a program very similar to this one and it does just that

Link??
improvshark #5
Posted 22 May 2013 - 01:35 AM
I was wondering if you could add a kill mob command also. The idea behind this is just having a sword on one side, enchant table peripheral on the other and the mobs are funneled to the turtle. The turtle kills some mobs collects the XP, enchants a book once in awhile, and it is a nice neat one turtle package.

I have made a program very similar to this one and it does just that

Link??

http://www.computercraft.info/forums2/index.php?/topic/12918-murderbot-the-xpenchanting-turtle/

something like this?
mangraa #6
Posted 28 May 2013 - 10:59 PM
*sigh* Ignore
MonthOLDpickle #7
Posted 06 June 2013 - 08:59 PM
Is there anyway to have the turtle print to a monitor? Say on top? chests on each side?