Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- enchant v2.1 by bigougit
- local dropDIR = "up"
- -- change for desired direction
- -- up, down, forward
- local enchantSlot = 1
- --slot used for enchanting
- local storageSlot = { 16, 15, 14 }
- --3 slots where books are stored
- local pullItems = "forward"
- --pull more items from dir
- --none, up, down, forward
- local xp
- if peripheral.getType("right") == "xp" then
- xp = peripheral.wrap("right")
- elseif peripheral.getType("left") == "xp" then
- xp = peripheral.wrap("left")
- else
- print("Must be ran on XP turtle!")
- return false
- end
- local continue = true
- local collected = 0
- local totEnchanted = 0
- local moreItems = {}
- moreItems["none"] = function() return false end
- moreItems["up"] = function() return turtle.suckUp() end
- moreItems["down"] = function() return turtle.suckDown() end
- moreItems["forward"] = function() return turtle.suck() end
- local dropTable = {}
- dropTable["up"] = function () return turtle.dropUp() end
- dropTable["down"] = function () return turtle.dropDown() end
- dropTable["forward"] = function() return turtle.drop() end
- local function dispStats()
- term.clear()
- term.setCursorPos(1,1)
- print("Bigougit's enchanting program.")
- print("XP collected: "..collected)
- print("Current level: "..xp.getLevels())
- print("Books Enchanted: "..totEnchanted)
- end
- if turtle.getItemCount(enchantSlot) ~= 1 then
- turtle.select(enchantSlot)
- dropTable[dropDIR]()
- turtle.select(storageSlot[1])
- turtle.transferTo(enchantSlot,1)
- end
- if turtle.getItemCount(storageSlot[2]) > 0 then
- turtle.select(storageSlot[2])
- turtle.transferTo(storageSlot[1],64)
- elseif turtle.getItemCount(storageSlot[3]) > 0 then
- turtle.select(storageSlot[3])
- turtle.transferTo(storageSlot[1],64)
- else
- print("pulling items")
- turtle.select(storageSlot[2])
- moreItems[pullItems]()
- turtle.select(storageSlot[3])
- moreItems[pullItems]()
- end
- turtle.select(storageSlot[1])
- while continue do
- collected = xp.collect() + collected
- dispStats()
- if xp.getLevels() > 29 then
- if turtle.getItemCount(enchantSlot) == 1 then
- turtle.select(enchantSlot)
- if xp.enchant(30) then
- totEnchanted = totEnchanted + 1
- while not dropTable[dropDIR]() do
- sleep(0.5)
- end
- turtle.select(storageSlot[1])
- if not turtle.transferTo(enchantSlot,1) then
- print("!!Need more books!!")
- if turtle.getItemCount(storageSlot[2]) > 0 then
- turtle.select(storageSlot[2])
- turtle.transferTo(storageSlot[1],64)
- elseif turtle.getItemCount(storageSlot[3]) > 0 then
- turtle.select(storageSlot[3])
- turtle.transferTo(storageSlot[1],64)
- else
- print("pulling items")
- turtle.select(storageSlot[2])
- moreItems[pullItems]()
- turtle.select(storageSlot[3])
- moreItems[pullItems]()
- end
- turtle.select(storageSlot[1])
- while not turtle.transferTo(enchantSlot,1) do
- collected = xp.collect() + collected
- dispStats()
- print("!!Need more books!!")
- sleep(0.5)
- end
- end
- else
- print("!!Error: Failed enchant!!")
- while not dropTable[dropDIR]() do
- collected = xp.collect() + collected
- sleep(0.5)
- end
- end
- end
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment