Jump to content




Last Question: Checking if an item is [blank]

turtle lua

2 replies to this topic

#1 Doobliheim

  • Members
  • 6 posts
  • LocationPortland, OR

Posted 24 November 2015 - 11:28 PM

Quick question. I have my fueling function, but I wanted to have the turtle to check it's other inventory slots for coal before it shuts off if it's designated "fuel" slow runs out. I was thinking of using the "turtle.getItemDetail()" and then using a boolean to check if the slot has an item with the name "minecraft:coal". How would I go about checking if the returned name information matches "minecraft:coal"?

Last question, I promise :P

#2 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

Posted 24 November 2015 - 11:33 PM

local x = "minecraft:iron"
if(x == "minecraft:coal") then
  --# Do stuff
end
local y = (x == "minecraft:coal")
if(y) then
  --#Do stuff
end


#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 24 November 2015 - 11:38 PM

You may be better off using turtle.refuel(0). This doesn't actually refuel the turtle, but it still returns true if the currently selected slot contains a valid fuel unit, or false if it does not.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users