I made a turtle xp grinder, auto enchants when level 30 is achieved or more if the current item selected cant be enchanted,
it displays a simple number showing the current level, but if there is no item in the turtles current items slot, the enchant returns a null value.
A while loop ends for some reason when there is a null value in the loop, here is my turtle xp grinder script.
I am not sure if I did something wrong, or if there is a way to ignore a null value, I would appreciate any help, because I cannot find anything on this, this was my last resort. :/
it displays a simple number showing the current level, but if there is no item in the turtles current items slot, the enchant returns a null value.
A while loop ends for some reason when there is a null value in the loop, here is my turtle xp grinder script.
PHP:
local PrevLev = 0
xp=peripheral.wrap("right")
while true do
turtle.attackUp()
if xp.getLevels() => 30 then
redstone.setOutput("bottom", false)
xp.setAutoCollect(false)
xp.enchant(30)
else
redstone.setOutput("bottom", true)
xp.setAutoCollect(true)
end
if xp.getLevels() > PrevLev then
print(xp.getLevels())
PrevLev = xp.getLevels()
end
if PrevLev > xp.getLevels() then
PrevLev = xp.getLevels()
end
sleep(0.1)
end