Bomb Bloke, on 28 June 2017 - 02:53 AM, said:
Because turtle.getItemDetail() returns nil on empty slots, and you can't index into nil to get a "name" key, a safer loop would look like:
local data = turtle.getItemDetail()
while not (data and data.name == "minecraft:sapling") do
print("Gimme a sapling")
os.pullEvent("turtle_inventory")
data = turtle.getItemDetail()
end
valithor, on 28 June 2017 - 02:06 AM, said:
It is spamming the text because you are never rechecking the slot. You get the value of the slot initially with local data = turtle.getItemDetail(), but you never update the data variable with the new information from the slot, so lets say the slot had dirt in it. If you never tell it to recheck the slot, data will always contain the information about the dirt that was in the slot.
Example:
Example:
local data = turtle.getItemDetail() --# get a initial value of the slot while data.name~="minecraft:sapling" do --# running the while loop while data.name does not equal "minecraft:sapling" data = turtle.getItemDetail() --# getting the new information about the slot sleep(5) --# sleep for 5 seconds so we are not spamming end
Thanks to both of you!
Works like a charm!
I assumed (for some reason) that it would update itself the way I did it.


Posted by
