Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local enchantWithLevel = 30
- local chestDir = "dropDown"
- local enchantChestSuck = "suckUp"
- local enchantChestDrop = "dropUp"
- m = peripheral.wrap("right")
- m.setAutoCollect(true)
- local work = true
- function drop_all_items()
- for i = 1, 16 do
- if turtle.getItemCount(i)~=0 then
- turtle.select(i)
- turtle[chestDir]()
- end
- end
- turtle.select(1)
- end
- function getFirstEmptySlot()
- for i = 1, 16 do
- if turtle.getItemCount(i)==0 then
- return i
- end
- end
- print("[SEVERE] Turtle was full!")
- drop_all_items() --drop all items if the turtle is full
- end
- function validEnchantLevel(x)
- if x>=1 and x<=30 then
- print("Yes")
- return true
- end
- print("No")
- return false
- end
- function enchant(lvl)
- if m.getLevels()>=lvl then
- if turtle.suckUp() then
- turtle.select(getFirstEmptySlot()-1)
- print(getFirstEmptySlot())
- turtle.dropUp(turtle.getItemCount(getFirstEmptySlot()-1)-1)
- if m.enchant(lvl) then
- print("Successfully enchanted an item from chest!")
- else
- print("Failed to enchant an item from chest!")
- end
- turtle.dropUp()
- turtle.select(1)
- return true
- else
- print("No item in the enchantment chest!")
- end
- end
- return false
- end
- function killndrop()
- local count = 0
- while os.pullEvent("start") do
- while work do
- if turtle.attack() then
- count = count + 1
- if count>=50 then
- drop_all_items()
- enchant(enchantWithLevel)
- count = 0
- end
- sleep(.25)
- else
- sleep(.5)
- end
- end
- print("Stopped killing these bitches :(")
- end
- end
- function keyInput()
- sleep(.1); os.queueEvent("start")
- local enchantWithLevel = enchantWithLevel
- while true do
- local event, char = os.pullEvent("char")
- if char == "s" then
- print("Stopping!")
- work = false
- sleep(2)
- break
- elseif char == "d" then
- print("Dropping items...")
- count = 0
- drop_all_items()
- count = 0
- elseif char == "n" then
- if m.getLevels()>=1 then
- print("Enchanting an item...")
- work = false
- sleep(1)
- print("\nChoose level to enchant with:")
- print("Use arrows on your keyboard to select")
- print("[DOWN] -1 level | +1 level [UP]")
- print("<- -5 levels | +5 levels ->")
- print("Press ENTER to enchant with chosen level")
- print("Current level: ".. tostring(m.getLevels()).." | Level chosen: "..tostring(enchantWithLevel))
- local runIt
- while true do --do until the loop will break
- local event, key = os.pullEvent("key")
- if key == 28 then --Enter
- if validEnchantLevel(enchantWithLevel) then
- if m.getLevels()>=enchantWithLevel then
- if m.enchant(enchantWithLevel) then
- print("Sucessfully enchanted!")
- break
- elseif enchant(enchantWithLevel) then
- print("Sucessfully enchanted!")
- break
- else
- print("Couldn't find an item to enchant!")
- print("Put it into the right chest or currently selected slot!")
- end
- else
- print("You don't have enough levels to enchant: \""..tostring(m.getLevels()).."\"")
- end
- end
- print("Press ESCAPE to exit the enchanting menu")
- elseif key == 200 then -- Arrow up
- if validEnchantLevel(enchantWithLevel + 1) then
- enchantWithLevel = enchantWithLevel + 1
- print("Currently selected level: "..enchantWithLevel)
- else
- print("Invalid enchantment level: "..(enchantWithLevel + 1))
- end
- elseif key == 208 then -- Arrow down
- if validEnchantLevel(enchantWithLevel - 1) then
- enchantWithLevel = enchantWithLevel - 1
- print("Currently selected level: "..enchantWithLevel)
- else
- print("Invalid enchantment level: "..(enchantWithLevel - 1))
- end
- elseif key == 203 then -- Arrow left
- if validEnchantLevel(enchantWithLevel - 5) then
- enchantWithLevel = enchantWithLevel - 5
- print("Currently selected level: "..enchantWithLevel)
- else
- print("Invalid enchantment level: "..(enchantWithLevel - 5))
- end
- elseif key == 205 then -- Arrow right
- if validEnchantLevel(enchantWithLevel) then
- enchantWithLevel = enchantWithLevel + 5
- print("Currently selected level: "..enchantWithLevel)
- else
- print("Invalid enchantment level: "..(enchantWithLevel + 5))
- end
- elseif key==1 or key==18 then -- ESCAPE
- print("Continuing...")
- break
- else
- print("You pressed the wrong key!")
- end
- end
- else
- print("You don't have enough levels to enchant something!")
- end
- print("Continuing...")
- work = true --return the state to "true" if it was set to false temporarily
- os.queueEvent("start")
- end
- end
- end
- if not validEnchantLevel(enchantWithLevel) then
- print("You selected an invalid enchant level: \""..tostring(enchantWithLevel).."\"\nStopping...")
- sleep(5)
- error()
- end
- print("Keys:")
- print("D - Urgently drop items")
- print("N - Enchant an item")
- print("S - Stop the turtle and exit")
- parallel.waitForAny(keyInput, killndrop)
- --by VADemon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement