Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local autoCollect = true
- local active = true
- local noBooks = false
- local function drop()
- if turtle.getItemCount(1) >= 60 then
- turtle.select(1)
- turtle.dropUp(turtle.getItemCount(1)-1)
- elseif turtle.getItemCount(2) >= 60 then
- turtle.select(2)
- turtle.dropUp(turtle.getItemCount(2)-1)
- turtle.select(1)
- elseif turtle.getItemCount(15)>0 then
- for i = 3, 15 do
- turtle.select(i)
- turtle.dropUp()
- end
- turtle.select(1)
- end
- end
- local function getBook()
- turtle.select(16)
- if not turtle.suckDown() then
- turtle.dropUp()
- if not turtle.suckDown() then
- noBooks = true
- else
- noBooks = false
- end
- else
- turtle.dropDown(turtle.getItemCount(16)-1)
- end
- turtle.select(1)
- end
- local function init()
- drop()
- xp = peripheral.wrap("right")
- xp.setAutoCollect(autoCollect)
- getBook()
- end
- local function enchant()
- if xp.getLevels()>=30 and not noBooks then
- turtle.select(16)
- xp.enchant(30)
- turtle.dropUp()
- getBook()
- elseif noBooks then
- getBook()
- end
- end
- local function output()
- term.clear()
- term.setCursorPos(1,1)
- print("Momentaner Level: ", xp.getLevels())
- if autoCollect then
- print("")
- print("XP-Autocollecting ist aktiviert,")
- print("zum Deaktivieren [A] druecken.")
- else
- print("")
- print("XP-Autocollecting ist deaktiviert,")
- print("zum Aktivieren [A] druecken.")
- end
- if active then
- print("")
- print("Wartungsmodus ist inaktiv,")
- print("zum Aktivieren [W] druecken.")
- else
- print("")
- print("Wartungsmodus ist aktiv,")
- print("zum Deaktivieren [W] druecken.")
- end
- if noBooks then
- print("")
- print("Keine Buecher mehr")
- end
- end
- local function wait()
- while true do
- if active then
- turtle.attack()
- drop()
- enchant()
- end
- output()
- sleep(.2)
- end
- end
- local function keypress()
- while true do
- local event, key = os.pullEvent("key")
- if key == 30 then
- autoCollect = not autoCollect
- xp.setAutoCollect(autoCollect)
- output()
- elseif key == 17 then
- active = not active
- output()
- end
- end
- end
- init()
- parallel.waitForAny(wait, keypress)
Advertisement
Add Comment
Please, Sign In to add comment