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

Detecting A Material

Started by H4X0RZ, 28 August 2013 - 06:31 PM
H4X0RZ #1
Posted 28 August 2013 - 08:31 PM
I've browsed trough the "Idea Exchange" topic and read this
It's possible. There are a variety of tests which can be performed to determine the type of material you have.

So, what are this tests to determine the material?
Bubba #2
Posted 28 August 2013 - 09:23 PM
I'll add to this list if I think of any more tests.

Gravel/Sand:
Go up two blocks, place the blocks below the turtle, and then see if they're still there.

Redstone/Lapis:
If upon digging four items are added to the turtles inventory, it's probably redstone or lapis ore.

Liquids:
A liquid source block can be determined by use of two empty buckets. Use turtle.placeDown() and then compare the buckets. If the compare is successful then the block below is not a liquid source block.
In order to detect a non-source block you can check if turtle.dig returns true twice.

Frequency test:
Blocks such as cobblestone, you can easily ascertain its type using a frequency test. If you encounter more than fifteen of the same block repetitively, you can almost be certain that it's cobblestone based on the MC distribution rules.

Does it smelt?:
If it does, then it must be gold, iron, cobblestone, or sand. And you can rule out both sand and cobblestone using above methods.

Crafting:
Craft something using the items with typical/cheap recipes. If they work then you can be certain of the item's type.

Map rules:
Use the MC distribution rules to your advantage. A large majority of land area will be cobblestone and dirt. You can keep those two blocks in your inventory for easy comparison. Use the above methods to separate some of the other frequent ores. Less common things such as rails from mineshafts stand out because you will encounter them so rarely.
Lyqyd #3
Posted 28 August 2013 - 09:40 PM
The challenge started you off at the base of a tree. From this tree, you know what logs are, what planks are, what sticks are, and what dirt is (the block below the log you start off in front of). From that starting point, you can expand your knowledge with a few facts about the blocks in your environment:

Stone: Becomes a different block when dug. The new block can be placed. The new block is smeltable.
Gravel: Falls, occasionally drops something different.
Sand: Falls, smeltable.
Grass: Becomes dirt when dug.
Logs of unknown trees: Craft by themselves into four items, which two of craft into sticks (which are known).
Coal ore: Drops a block-incomparable item, which can smelt items, and is fuel.
Iron ore: Smelts, isn't stone/cobblestone. Smelting product creates turtles.
Gold ore: Smelts, smelting product creates monitors.
Redstone ore: Drops multiple items, crafting with a stick is successful.
Lapis ore: Drops multiple items, crafting with a stick is unsuccessful.
Diamond ore: Drops single block-incomparable item, isn't fuel. Crafts into a pickaxe.
Reeds: Create paper when crafted.
Lava: Liquid checks, and is fuel.
Water: Liquid checks, and isn't fuel.

Anything else either doesn't matter, or… doesn't matter, for the purposes of the challenge.
immibis #4
Posted 29 August 2013 - 05:09 AM
Where did the OP mention the turtle duplication challenge thing?
Another test to try is to emit a redstone signal, then read it back (using rs.getInput) to see if the block conducted redstone. I haven't tried that in-game, but if it works it will tell you whether the block is solid.
theoriginalbit #5
Posted 29 August 2013 - 05:22 AM
To add on what Lyqyd and Bubba stated…

Since CC 1.5 we have been able to supply a number of 0 to turtle.craft and turtle.refuel… This allows us to check whether an item is a fuel source, or if the current grid is craftable, without consuming or crafting the item. So when attempting to discover fuel sources, or things based off recipes, remember to use

turtle.refuel(0)
and

turtle.craft(0)
CCJJSax #6
Posted 30 August 2013 - 10:00 PM
also redstone is placeable, lapis is not
floppyjack #7
Posted 01 September 2013 - 07:09 AM
You can test if something is smeltable by putting it in the furnace and taking it out again before it has the chance to get consumed. Then you just check if the fuel is still there. (use cheap fuel)