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

turtle.getItemId()?

Started by creepig, 05 October 2012 - 11:39 AM
creepig #1
Posted 05 October 2012 - 01:39 PM
I know that you can compare items in a slot with known items in another slot to determine what item is in the selected slot, but that seems horribly inefficient to me, especially when working with large numbers of vanilla blocks. I really think that the Turtle API needs a getItemId() function that just returns the ID number (and maybe the damage value) of the item in the slot and leaves it up to the programmer to do the comparison. That would also allow for switching statements that perform different actions based on the ID value, leading to more efficient code.
Kolpa #2
Posted 05 October 2012 - 01:50 PM
it was already said that this is not going to happen
Pyrodogg #3
Posted 05 October 2012 - 05:45 PM
I know Dan is against this cause it's OP, lawl. Someday when I get time… i think i'm going to add this in to my own turtles.

It bothers me fundamentally. We now have turtles that can print pages, and books. They can communicate wirelessly, innately know what redstone wires are and can't frakking tell if blocks are dirt or stone </rant>
creepig #4
Posted 05 October 2012 - 11:49 PM
I know Dan is against this cause it's OP, lawl.

Blocks that can craft, dig, move, and place blocks are not OP, but being able to more intelligently determine what's in your inventory is? I'll be blunt, that's downright stupid. I don't even see how it could be OP. It's simply a more efficient way of doing the same thing, without wasting unnecessary processor cycles by doing it inefficiently.
Orwell #5
Posted 06 October 2012 - 12:13 AM
I know Dan is against this cause it's OP, lawl.

Blocks that can craft, dig, move, and place blocks are not OP, but being able to more intelligently determine what's in your inventory is? I'll be blunt, that's downright stupid. I don't even see how it could be OP. It's simply a more efficient way of doing the same thing, without wasting unnecessary processor cycles by doing it inefficiently.

Teleporting turtles are even more efficient. But all that just defeats the purpose. Computers/turtles are blind, they don't have eyes and crazy advanced image processors or some sort of sensors that recognize a hundres materials. It's just a clear border between a dumb moving block and an absurdly intelligent drone.
PixelToast #6
Posted 06 October 2012 - 12:37 AM
i suggested being able to get an items metavalue awhile ago, they didnt like it :C, i dont get why, its so useful
Kolpa #7
Posted 06 October 2012 - 03:25 AM
i suggested being able to get an items metavalue awhile ago, they didnt like it :C, i dont get why, its so useful

Reading helps :D/>/> 2 people infront of you just explained

I know Dan is against this cause it's OP, lawl. Someday when I get time… i think i'm going to add this in to my own turtles.

It bothers me fundamentally. We now have turtles that can print pages, and books. They can communicate wirelessly, innately know what redstone wires are and can't frakking tell if blocks are dirt or stone </rant>
I know Dan is against this cause it's OP, lawl.

Blocks that can craft, dig, move, and place blocks are not OP, but being able to more intelligently determine what's in your inventory is? I'll be blunt, that's downright stupid. I don't even see how it could be OP. It's simply a more efficient way of doing the same thing, without wasting unnecessary processor cycles by doing it inefficiently.

Teleporting turtles are even more efficient. But all that just defeats the purpose. Computers/turtles are blind, they don't have eyes and crazy advanced image processors or some sort of sensors that recognize a hundres materials. It's just a clear border between a dumb moving block and an absurdly intelligent drone.
creepig #8
Posted 06 October 2012 - 03:57 AM
I know Dan is against this cause it's OP, lawl.

Blocks that can craft, dig, move, and place blocks are not OP, but being able to more intelligently determine what's in your inventory is? I'll be blunt, that's downright stupid. I don't even see how it could be OP. It's simply a more efficient way of doing the same thing, without wasting unnecessary processor cycles by doing it inefficiently.

Teleporting turtles are even more efficient. But all that just defeats the purpose. Computers/turtles are blind, they don't have eyes and crazy advanced image processors or some sort of sensors that recognize a hundres materials. It's just a clear border between a dumb moving block and an absurdly intelligent drone.

And yet they somehow have the ability to tell if this is the same as that without having "crazy advanced image processors" to recognize materials. If they can't tell what something is, they can't tell if it's the same as something else. It's as simple as that, and the idea that they somehow shouldn't be capable of distinguishing is quite simply completely absurd.
Sebra #9
Posted 06 October 2012 - 07:35 AM
Check Peripheral section. Several Turtle Upgrades able to help you made already.

Someone definitely need to make "Denied suggestions and ToDo list" pinned in this section.
Cloudy #10
Posted 06 October 2012 - 01:01 PM
Dan has never said its OP. Dan had only said it would break the fourth wall. Capabilities exist to compare items in the turtles inventory. There is no need to expose item ID's - if someone can prove that the existing capabilities are not enough then sure, we will think of solutions - however all we have been told is that they are difficult to use. Which isn't valid enough to be honest.
PonyKuu #11
Posted 06 October 2012 - 03:11 PM
if someone can prove that the existing capabilities are not enough then sure, we will think of solutions
My recent peatfarm example? Wheat growth detection? Lapis/redstone/nikolite/diamond/coal/uranium detection?

Other "white spot" - is the inventory interaction, since there are only two options - suck and drop.
Sebra #12
Posted 06 October 2012 - 03:25 PM
Yes. To distinguish blocks which cannot be in inventory. Even with Silk Touch.
Cloudy #13
Posted 06 October 2012 - 03:29 PM
if someone can prove that the existing capabilities are not enough then sure, we will think of solutions
My recent peatfarm example? Wheat growth detection? Lapis/redstone/nikolite/diamond/coal/uranium detection?

Other "white spot" - is the inventory interaction, since there are only two options - suck and drop.

Wheat growth detection wouldn't be able to be handled like this anyway - and the rest of them can be done if you provide a turtle with a block using silk touch (which is easier than ever to get in 1.3.2). Besides - I think the best way of detecting an item is being destructive - digging, and checking if an item has increased, or using turtle.compareTo() if it goes into a new slot. There is no way of us detecting what item is going to go into the slot at the time we mine, since it could be different every time we call it. Case in point, gravel and flint.

Suck and drop are more than enough to do most inventory interactions, including sorting etc. You just need a little ingenuity - where would the fun be if everything was handled to you on a plate?
PonyKuu #14
Posted 06 October 2012 - 04:33 PM
Wheat growth detection wouldn't be able to be handled like this anyway - and the rest of them can be done if you provide a turtle with a block using silk touch
And we have to start laking about inventory space. - there are 16 slots, and if you are playing with some mods - there are tons of different resources underground. And you have to tell turtle to mine all of them. Anyways, there a a solution, but… I don't talk about getItemID (), but some things are missing - like that wheat issue…
Besides - I think the best way of detecting an item is being destructive - digging, and checking if an item has increased, or using turtle.compareTo() if it goes into a new slot. There is no way of us detecting what item is going to go into the slot at the time we mine, since it could be different every time we call it. Case in point, gravel and flint.
Sometimes you want to know, whether that block worth mining or not to save inventory space and time. Destructive way in that cas - is not the way.
Suck and drop are more than enough to do most inventory interactions, including sorting etc. You just need a little ingenuity - where would the fun be if everything was handled to you on a plate?
Well, it's not enough really, since you can't have a chest with dirt and sand and have turtle make that… bog earth. You have to make a separate chest for dirt, and a separate chest for sand - that's an issue. Well, there are tons of dirt and sand, but if you want to use something more… rare in crafting - you should have a separate chest for each item. it's kinda siily, isn't it?
Cloudy #15
Posted 06 October 2012 - 04:50 PM
Sometimes you want to know, whether that block worth mining or not to save inventory space and time. Destructive way in that cas - is not the way.
But there is no way round it - I'm sorry about that, but there are technical concerns when it comes to comparing what you will receive when you're going to mine, before you actually do it - because there is really no way of doing it.
Well, it's not enough really, since you can't have a chest with dirt and sand and have turtle make that… bog earth. You have to make a separate chest for dirt, and a separate chest for sand - that's an issue. Well, there are tons of dirt and sand, but if you want to use something more… rare in crafting - you should have a separate chest for each item. it's kinda siily, isn't it?

No. It isn't. Chests are cheap - and if something is rare in crafting, surely you won't have more than 8 stacks of each - you can easily pull in many stacks from the chest, and then put back things that you don't want. It isn't rocket science.
PonyKuu #16
Posted 06 October 2012 - 05:05 PM
But there is no way round it - I'm sorry about that, but there are technical concerns when it comes to comparing what you will receive when you're going to mine, before you actually do it - because there is really no way of doing it.
OK, but can we solve somehow the wheat issue? Maybe special function for the farming turtle, which detects whether it has grown or not?
No. It isn't. Chests are cheap - and if something is rare in crafting, surely you won't have more than 8 stacks of each - you can easily pull in many stacks from the chest, and then put back things that you don't want. It isn't rocket science.
Yeah, but the main problem - is free space…
And, the thing I really don't like - is that any inventory is a black box. There are no way to know is there are something, and how much. By hand you can open the chest and look into it, but turtle can only suck items, and count them… And if there are no space in turtle's inventory - you should place items somwhere else, while you try to figure it out. Maybe some sort of inventory peripheral would be nice? For example, you peripheral.wrap() that inventory and be able to select slots in that inventory, count them and compare to something inside turtle's inventory…
Cloudy #17
Posted 06 October 2012 - 05:42 PM
OK, but can we solve somehow the wheat issue? Maybe special function for the farming turtle, which detects whether it has grown or not?

Look into database turtle peripheral.

Yeah, but the main problem - is free space…
And, the thing I really don't like - is that any inventory is a black box. There are no way to know is there are something, and how much. By hand you can open the chest and look into it, but turtle can only suck items, and count them… And if there are no space in turtle's inventory - you should place items somwhere else, while you try to figure it out. Maybe some sort of inventory peripheral would be nice? For example, you peripheral.wrap() that inventory and be able to select slots in that inventory, count them and compare to something inside turtle's inventory…

Turtles are going to remain blind when it comes to reading from an inventory - if you know you're reading from an inventory, you will have some idea as to what will be in that inventory anyway.

However, coming soon ™:

turtle.transfer( slot, [count] )
PonyKuu #18
Posted 06 October 2012 - 05:48 PM
Oh, mods for mods… Don't like that… OK, maybe I'll try that eventually…

Transfer sounds cool. Does it move a <count> number of items from selected slot to <slot>?
Cloudy #19
Posted 06 October 2012 - 06:21 PM
Yep!
PonyKuu #20
Posted 06 October 2012 - 07:37 PM
Nice!
Sebra #21
Posted 06 October 2012 - 09:40 PM
Cloudy, have you speak with Dan200 about detecting air, void, liquid, solid and such?
What was results?
D3matt #22
Posted 08 October 2012 - 10:22 PM
So cloudy, if getting item IDs and metadata breaks the fourth wall, how about this?

turtle.associate(slot, ID). You can memorize an item in its inventory for later comparison without having to carry it around all the time. slot being the slot to memorize, ID being the ID you want to save it as. Since the ID is provided by the program instead of "Oh, I know, that's ItemID 1!", the 4th wall remains unbroken. Of course, an accompanying function would be needed to compare a block in front of the turtle to a stored item ID (Or maybe to return which stored ID it matches, or false. That would speed things up.).

Yay or nay?
immibis #23
Posted 09 October 2012 - 01:42 AM
So cloudy, if getting item IDs and metadata breaks the fourth wall, how about this?

turtle.associate(slot, ID). You can memorize an item in its inventory for later comparison without having to carry it around all the time. slot being the slot to memorize, ID being the ID you want to save it as. Since the ID is provided by the program instead of "Oh, I know, that's ItemID 1!", the 4th wall remains unbroken. Of course, an accompanying function would be needed to compare a block in front of the turtle to a stored item ID (Or maybe to return which stored ID it matches, or false. That would speed things up.).

Yay or nay?

I think I suggested that when turtle.compare was added, and it still hasn't happened, so it seems unlikely.

Edit: Database turtles, from Aperture Science Turtle Upgrades, can do this.