38 posts
Posted 07 June 2015 - 03:03 AM
What's going on, guys?
I've heard that there is code where a turtle can sense how many and what type of items it picks up. I am basically making a bank-type program. I want a certain amount of one item to execute a command (such as redstone.setOutput()). Help will be much appreciated. Thanks!
3057 posts
Location
United States of America
Posted 07 June 2015 - 03:09 AM
38 posts
Posted 07 June 2015 - 03:35 PM
Thanks, but I want to make an "if" statement with this info. Something like: 'if data == "iron_ingot" then'.
7083 posts
Location
Tasmania (AU)
Posted 07 June 2015 - 03:50 PM
So do that.
local data = turtle.getItemDetail()
if data and data.name == "minecraft:iron_ingot" then -- If data is defined (meaning there was an item in the slot), and the item's name matches, then...
-- whatever
end
It is, of course, rather difficult to tell you how to improve your script if you don't want to show it to us.
38 posts
Posted 07 June 2015 - 04:23 PM
So do that.
local data = turtle.getItemDetail()
if data and data.name == "minecraft:iron_ingot" then -- If data is defined (meaning there was an item in the slot), and the item's name matches, then...
-- whatever
end
It is, of course, rather difficult to tell you how to improve your script if you don't want to show it to us.
Still doesn't work… I am on minecraft 1.7.10, does it work there?
3057 posts
Location
United States of America
Posted 07 June 2015 - 05:31 PM
MC version rarely makes a difference in CC features, the CC version is more important. However, if you had said minecraft 1.6, I could've told you it isn't added yet.
if the script BB provided errors with
filename:1:attempt to call nil
…You don't have that functionality in your version of CC, and may want to consider updating.
If you used his code and nothing happened, you do have the functionality but didn't add any code inside the if statement provided, or the turtle didn't find an iron ingot in the currently selected slot (default is slot 1, upper left).