This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Angry_Dragonoid's profile picture

Turtles Detecting items?

Started by Angry_Dragonoid, 27 February 2016 - 01:40 AM
Angry_Dragonoid #1
Posted 27 February 2016 - 02:40 AM
Hello,

I am trying to write a series of programs for inventory management with turtles. The first thing I'm working on is Furnace management. Similar to Nitrogen finger's version, but with my own twist.

The main thing I'm having an issue with is the management. I want to figure out how to get the turtle to detect the difference between furnace fuel and smeltable items…now I KNOW I could just make it so that you HAVE to put fuel in slot 1, and items in slot 2, etc…but that's too simple for my taste. If I have to use tables I'm find with it. Just give me the starting piece of it, so I know the basic layout, (I'm still trying to learn tables) and maybe tell me how to add on to it?

Thanks in advance!

AngryDragonoid
Dragon53535 #2
Posted 27 February 2016 - 03:00 AM
A turtle uses the same fuel that a furnace uses.


for i = 1,16 do
  turtle.select(i)
  if turtle.fuel(0) then
	print("Item in slot " .. i .. " can be used for fuel")
  end
end
Edited on 27 February 2016 - 02:00 AM
KingofGamesYami #3
Posted 27 February 2016 - 03:09 AM

for i = 1,16 do
  turtle.select(i)
  if turtle.refuel(0) then
	print("Item in slot " .. i .. " can be used for fuel")
  end
end

Fixed your code :)/>
Dragon53535 #4
Posted 27 February 2016 - 05:37 AM
A turtle uses the same fuel that a furnace uses.


for i = 1,16 do
  turtle.select(i)
  if turtle.refuel(0) then
	print("Item in slot " .. i .. " can be used for fuel")
  end
end

Edit: Thanks KoGY, forgot that it's turtle.refuel and not turtle.fuel
Angry_Dragonoid #5
Posted 27 February 2016 - 03:44 PM
1) I'm on unlimited fuel.
2) That won't work for normal items too will it? Items to be smelted??
Dragon53535 #6
Posted 28 February 2016 - 03:16 AM
turtle.refuel(0) is really just a check, it "tries" to refuel with the item that is selected by using exactly 0 of that item. If the item was a fuel item then it could use that item and it returns true, however it doesn't consume it since it used 0. It's the easiest way of checking if certain items are fuel without caring which item it is exactly.
Silver07 #7
Posted 04 March 2016 - 06:11 AM
Things that would make turtles better.
a way to get the ID of a block returns string "minecraft:block"
a way to get the ID of a block or item in inventory returns string "minecraft:block", or "minecraft:item"
a way to get the ID of a block or item in a specified slot in a chest that is in front above or below the turtle returns string "minecraft:item", or "minecraft:block"
a way to get the ID of a block or item in a specified slot in a furnace that is in front above or below the turtle returns string "minecraft:item", or "minecraft:block"
ex: turtle.getItem(slot)
ex: turtle.getBlock()
ex: turtle.getBlockUp()
ex: turtle.getContainerItem(slot)
Dragon53535 #8
Posted 04 March 2016 - 08:53 AM
Perhaps your ideas would be better suited for the suggestions forum.
Lupus590 #9
Posted 04 March 2016 - 01:49 PM
Things that would make turtles better.
a way to get the ID of a block returns string "minecraft:block"
a way to get the ID of a block or item in inventory returns string "minecraft:block", or "minecraft:item"
a way to get the ID of a block or item in a specified slot in a chest that is in front above or below the turtle returns string "minecraft:item", or "minecraft:block"
a way to get the ID of a block or item in a specified slot in a furnace that is in front above or below the turtle returns string "minecraft:item", or "minecraft:block"
ex: turtle.getItem(slot)
ex: turtle.getBlock()
ex: turtle.getBlockUp()
ex: turtle.getContainerItem(slot)

http://computercraft.info/wiki/Turtle.getItemDetail