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

[CC 1.4.8][MC 1.4.6]Turtle Item Analyzer

Started by someone9999, 10 November 2012 - 02:56 PM
someone9999 #1
Posted 10 November 2012 - 03:56 PM
This mod for computer craft contains an item analyzer for computer craft which allows Items to be analyzed by a turtle. The turtle is able to read the name, id, metadata (damage), and count of any item in the turtle's inventory.

Works for multiplayer

Why this was made:
SpoilerThis mod was made because a turtle would be perfect to use as a sorting system, but was always missing the ability to test an item's id without having something to compare it to. This mod fixes that by allowing any turtle to see the item id of any item in their inventory.

I had searched around on this form earlier to see if another mod did this task, but was not able to find one. The closest I could find were ARP pipes by Xfel http://www.computerc...now-for-mc-142/ but this did not quite do the job I wanted, and it has not been updated to the latest version of minecraft.

Searching the forums I had found that others were wanting this simple tool also. http://www.computerc...amount-checker/
This link is from august, but it is asking for exactly what I have added to computer craft.

Note that the reason that the mod id is called someone9999.addons is because I am planning to add more addons to computer craft because I really enjoyed using the computer craft API.

This mod adds an analytical turtle which can be used to determine the block id or metadata of any block or item in it's inventory

Crafting Recipes
SpoilerAnalyzer


AnalyiticalTurtle

Images
Spoiler

Methods that you can call using this turtle upgrade.
"analyzer" is the variable that the peripheral is wrapped to in these examples.

Note: The latest update makes it so most methods that can be called now return a string describing an error if it fails. This is configurable in the config options to return false only. This may break pre 2.2 programs. Sorry for the inconvenience.


--Note that anytime slot is sent as an argument, it's valid values are integer values
--starting from 1 to the inventory size.

analyzer.getBlockId()
--Returns the block Id of the currently selected block in the turtle's inventory.

analyzer.getBlockIdAt(slot)
analyzer.getBlockIdAtUp(slot)
analyzer.getBlockIdAtDown(slot)
--Returns the block Id of the slot sent as an argument in the adjacent inventory above, infront, or below the turtle.
--This counts as a "check" for fuel usage.

analyzer.getBlockName()
--Returns a string containing the localized block name in the currently selected slot in the turtle's inventory.
--Items named with the anvil will NOT return their custom name, this is a known bug.

analyzer.getBlockNameAt(slot)
analyzer.getBlockNameAtUp(slot)
analyzer.getBlockNameAtDown(slot)
--Returns a string containing the localized block name in the send argument in the adjacent inventory above, infront, or below the turtle.
--This counts as a "check" for fuel usage.
--Items named with the anvil will NOT return their custom name, this is a known bug.

analyzer.getBlockMetadata()
--Returns the metadata of the currently selected block in the turtle's inventory, or the item damage if the selected block is an item.

analyzer.getBlockMetadataAt(slot)
analyzer.getBlockMetadataAtUp(slot)
analyzer.getBlockMetadataAtDown(slot)
--Returns the metadata of the selected slot in the adjacent inventory above, infront, or below the turtle.
--This counts as a "check" for fuel usage.

analyzer.getBlockCount()
--Returns the number of blocks or items in the currently selected slot in the turtles inventory.

analyzer.getBlockCountAt()
analyzer.getBlockCountAtUp()
analyzer.getBlockCountAtDown()
--Returns the number of blocks or items in the selected slot in the adjacent inventory above, infront, or below the turtle.
--This counts as a "check" for fuel usage.


analyzer.placeAt(slot)
analyzer.placeAtUp(slot)
analyzer.placeAtDown(slot)
--Places the selected item in the turtle's inventory into the selected slot in the container infront, above, or below the turtle.
--This counts as an "action" for fuel usage.

analyzer.takeAt(slot)
analyzer.takeAtUp(slot)
analyzer.takeAtDown(slot)
--Takes the selected item in the container infront, above, or below the turtle into the selected slot in the turtle
--This counts as an "action" for fuel usage.

analyzer.getCheckUsesLeft()
--Returns the number of checks the turtle can do until more fuel is required.

analyzer.getActionUsesLeft()
--Returns the number of actions the turtle can do until more fuel is required.


Example Code:
Spoiler

local analyzer = peripheral.wrap("right")
turtle.select(1)
turtle.dig()
print("I just dug " .. analyzer.getBlockName())


Download:

2.3 (MC 1.4.6) (CC 1.4.8) Universal
2.2 (MC 1.4.6) (CC 1.4.8) Universal (Warning: takeAt() and placeAt() have serious bugs in this version)
2.1 (MC 1.4.4) (CC 1.4.7) Universal
2.0 (MC 1.4.2) (CC 1.4.6) Universal
1.0 (MC 1.4.2) (CC 1.4.6) Universal


Change Log:
Spoiler2.2
  • Ported to Minecraft 1.4.6
  • Fixes metadata not carrying over on takeAt and placeAt calls.
  • More descriptive errors are now given when the analyzer fails.
  • Fuel is now required for the analyzer to function. 1 fuel is taken after every 5 "actions" (takeAt, placeAt), and after every 10 "checks" (getBlockIdAt, getBlockCountAt, etc…). Checks that only affect the turtle's inventory are not affected by these fuel requirements.
  • Config option to adjust fuel requirements.
  • Methods to figure out how many checks or actions are left until more fuel is used.
2.1
  • Ported to Minecraft 1.4.4
2.0
  • Added ability to configure which methods are allowed to be called in config.
  • Added the ability to find out information about blocks in adjacent inventories to turtles. (Analyzer Upgrade).
  • Added the ability to place and take items out of specific slots in adjacent inventories to turtles. (Analyzer Upgrade).
  • Changed getBlockCount to return 0 instead of -1 if there is no block at the selected slot. (Analyzer Upgrade).
1.0
  • First Release
cant_delete_account #2
Posted 10 November 2012 - 07:34 PM
Totally wrong thread, oops.
Shnupbups #3
Posted 10 November 2012 - 08:39 PM
Added analytic turtle to official list of turtle upgrade ids on the wiki.
someone9999 #4
Posted 10 November 2012 - 08:51 PM
With forestry installed I'm getting an error, it's like:

faubiguy.xpupgrade.XPUpgradeItem cannot be cast to forestry.core.items.ItemCrated

You have an item ID conflict with the XP upgrade mod and the forestry mod (the crated netherwart item and the XP Upgrade item). Try changing the XP Upgrade Item Id in the config file "XPUpgrade" under /%appdata%/.minecraft/config/

That should fix your problem.

Added analytic turtle to official list of turtle upgrade ids on the wiki.

Thank you.


Edit:

Version 2.0 of Computer Craft Analyzer released.

Changes include:
  • Added ability to configure which methods are allowed to be called in config.
  • Added the ability to find out information about blocks in adjacent inventories to turtles. (Analyzer Upgrade).
  • Added the ability to place and take items out of specific slots in adjacent inventories to turtles. (Analyzer Upgrade).
  • Changed getBlockCount to return 0 instead of -1 if there is no block at the selected slot. (Analyzer Upgrade).
Marval #5
Posted 11 November 2012 - 11:19 PM
Would it be possible to make this for MC 1.2.5? I'm sure that many peopole still playing on 1.2.5 because of some mods that still didn't upgrade to 1.4.2 (f.e. RedPower). And your mod is owesome. I already have a lot of applications for this.
someone9999 #6
Posted 12 November 2012 - 01:40 PM
Would it be possible to make this for MC 1.2.5? I'm sure that many peopole still playing on 1.2.5 because of some mods that still didn't upgrade to 1.4.2 (f.e. RedPower). And your mod is owesome. I already have a lot of applications for this.

No, sorry. The changes between 1.2.5 and 1.4.2 are huge, and this would require a large amount of work due the client side and server side code being split up, and the inability to use many forge API's that my mod currently requires to function. This is also the same reason that many mods have been taking so long to update is because of these massive changes.

I miss Red Power 2 as well in the latest minecraft, but It would be too much work to add backwards compatibility to the Item Analyzer to allow for compatibility with minecraft 1.2.5.


Unreleated Edit:

Computer Craft Analyzer ported to minecraft 1.4.4
cant_delete_account #7
Posted 17 November 2012 - 04:24 PM
I was gonna post that error on the XP Turtle thread, oops.
Mitchfizz05 #8
Posted 24 November 2012 - 02:40 AM
I have a suggestion for the RFID card writers.
Can you make a method like 'whatever.closeLid()' or 'whatever.lock(true/false)' so you can close the glass block thing through code?
I have made a simple program that is simply for writing data to RFID cards, but after it checks if the card in in the reader, and before it writes data, it is possible to just take the card out, and then cause problems.
Orwell #9
Posted 24 November 2012 - 05:31 AM
I have a suggestion for the RFID card writers.
Can you make a method like 'whatever.closeLid()' or 'whatever.lock(true/false)' so you can close the glass block thing through code?
I have made a simple program that is simply for writing data to RFID cards, but after it checks if the card in in the reader, and before it writes data, it is possible to just take the card out, and then cause problems.
Are you sure this is the right thread?
Viproz #10
Posted 24 November 2012 - 06:38 AM
please add a getBlockIdFoward() to give us the id of the block in front of the turtle
someone9999 #11
Posted 24 November 2012 - 08:35 PM
please add a getBlockIdFoward() to give us the id of the block in front of the turtle

Hmm… I like it.

Ill likely include this in the next release, although it will probably cost fuel or something. (dont worry, config option)

Thanks for the suggestion.
immibis #12
Posted 24 November 2012 - 10:17 PM
I have a suggestion for the RFID card writers.
Can you make a method like 'whatever.closeLid()' or 'whatever.lock(true/false)' so you can close the glass block thing through code?
I have made a simple program that is simply for writing data to RFID cards, but after it checks if the card in in the reader, and before it writes data, it is possible to just take the card out, and then cause problems.
This is the wrong thread, but you can check whether encode returns an error message - it returns true on success, or an error message on failure.
Nietsnie #13
Posted 26 November 2012 - 09:05 AM
Thanks for the great mod! It was super useful in my automated bee farm.
huldu #14
Posted 11 December 2012 - 10:56 AM
How come this isn't popular? It's probably one of the best things for the turtle to have, just a shame it takes up a slot… But still how come the turtle by default can't identify what item it got in a slot? It can do pretty much anything but not that… item compare, seriously?

Anyways great job on making this. I had no idea it even existed until I by accident found it on a forum linking here.
Tiin57 #15
Posted 11 December 2012 - 12:46 PM
How come this isn't popular?
This community seems to dislike over-powered mods. :P/>
Except mine. Mine was awesome. (Don't bother looking for it. An admin removed it for ruining the forums with its beauty. :D/>)
Nietsnie #16
Posted 12 December 2012 - 08:00 AM
Hmm, I'm not sure I'd call it overpowered. I guess it depends on what your definition of a turtle is. I tend to think of them as automated replacements for a player. A player can easily look in a container, determine what is there, and move things from specific slots.

I think this mod nicely extends turtles with some missing functionality. It's not like you click a button and get diamonds or something :)/>
immibis #17
Posted 12 December 2012 - 12:40 PM
Hmm, I'm not sure I'd call it overpowered. I guess it depends on what your definition of a turtle is. I tend to think of them as automated replacements for a player. A player can easily look in a container, determine what is there, and move things from specific slots.

I think this mod nicely extends turtles with some missing functionality. It's not like you click a button and get diamonds or something :)/>/>

I think the main reason this hasn't been implemented in CC is that it would have to expose item IDs to the player. ASTU has database turtles, which can identify items without using IDs (you have to set your own IDs that the turtle uses) and would fit in CC.
PixelToast #18
Posted 12 December 2012 - 04:30 PM
items can have negative damage values, so getmetadata might return -1 for something that exist
etopsirhc #19
Posted 17 December 2012 - 09:43 PM
like the idea just not the implementation , i'd prefer it to return a unique item hash, that way you cant just tell a turtle to mine untill it fills its inventory with 264 XP
Nietsnie #20
Posted 18 December 2012 - 03:34 PM
Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
someone9999 #21
Posted 18 December 2012 - 09:37 PM
How come this isn't popular? It's probably one of the best things for the turtle to have, just a shame it takes up a slot… But still how come the turtle by default can't identify what item it got in a slot? It can do pretty much anything but not that… item compare, seriously?

Anyways great job on making this. I had no idea it even existed until I by accident found it on a forum linking here.
Thank you.

How come this isn't popular?
This community seems to dislike over-powered mods. :P/>
Except mine. Mine was awesome. (Don't bother looking for it. An admin removed it for ruining the forums with its beauty. :D/>)
The CCMPU was quite fun to play with :)/>, shame it was removed. I had a automated tower creator program for that peripheral.
(Sorry if the spelling is wrong, can't remember the exact name).

On a related note, there will likely be a nerf for the item analyzer. It's going to cost fuel in the future to use it. (config option).

items can have negative damage values, so getmetadata might return -1 for something that exist
Oh, really. That must have slipped my mind. Thanks for the heads up, I'll probably change it to return a string describing the error. (config option to maintain compatibility with created programs).

like the idea just not the implementation , i'd prefer it to return a unique item hash, that way you cant just tell a turtle to mine untill it fills its inventory with 264 XP
Hmm… I understand what your saying, It can be a pain at times to read and check two value vs one value depending on the item. I'm not crazy about doing a hash, but I'll think about the issue, and possibly add different read method (config option).


Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
Sorry, I don't know the reasoning behind it. I'll look into it. Thanks for the heads up on the incompatibility.
immibis #22
Posted 18 December 2012 - 09:52 PM
Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
Sorry, I don't know the reasoning behind it. I'll look into it. Thanks for the heads up on the incompatibility.
It could be that your code removes (or doesn't copy) NBT data on items (the stackTagCompound field)
PixelToast #23
Posted 19 December 2012 - 07:07 AM
forest drone is the default for bees without the "tag" compound
yea, its not copying NBT correctly
Marval #24
Posted 20 December 2012 - 11:55 PM
Is possible, using your addon, to take specified amount of items from selected slot or this always take whole stack?
Kalembas #25
Posted 21 December 2012 - 10:31 AM
Does this peipheral always take the "right" slot? If so, there is no opportunity to make a wireless analyzing turtle (modem takes the "right" slot), which makes this functionality incomplete. Am I wrong?

— EDIT —-

Found the answer. Thats an elegant workaround. Good Job!
Kalembas #26
Posted 21 December 2012 - 12:49 PM
Is there a possibility to have a method that returns a number of slots in the adjacent inventory?
And its definetely is a good idea to be able to take/put a defined quantity of items.
infAl #27
Posted 21 December 2012 - 10:22 PM
Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
Sorry, I don't know the reasoning behind it. I'll look into it. Thanks for the heads up on the incompatibility.
I also noticed something odd with IC2 Energy Crystals. I had an MFSU set up to charge the crystal, the turtle checks to see if metadata is 1 (fully charged), if so it pulls the crystal and places it in slot 2 of a nearby MFE. The problem is that as soon as the crystal goes in to the MFE, it's metadata changes to 26, which is completely depleted and no charge is tranferred to the MFE.
someone9999 #28
Posted 21 December 2012 - 10:45 PM
Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
Sorry, I don't know the reasoning behind it. I'll look into it. Thanks for the heads up on the incompatibility.
It could be that your code removes (or doesn't copy) NBT data on items (the stackTagCompound field)

Yeah, I didn't think to do that. Thanks.
Is possible, using your addon, to take specified amount of items from selected slot or this always take whole stack?
It's coming. It's already in my current dev-build.

Any ideas why, with the latest version of forestry, using the analyzer.takeAt() functionality somehow screws up the bee data? They get revered to a white drone, and when analyzed, turn into a forest drone. This has only started in Forestry 1.6.2.9 or so.
Sorry, I don't know the reasoning behind it. I'll look into it. Thanks for the heads up on the incompatibility.
I also noticed something odd with IC2 Energy Crystals. I had an MFSU set up to charge the crystal, the turtle checks to see if metadata is 1 (fully charged), if so it pulls the crystal and places it in slot 2 of a nearby MFE. The problem is that as soon as the crystal goes in to the MFE, it's metadata changes to 26, which is completely depleted and no charge is tranferred to the MFE.

This issue *should* be fixed in the next release as the issue seems to be the same as the forestry bug. Im going to try and release a new version that fixes this within the next few days.
Ehrlingby #29
Posted 22 December 2012 - 12:51 AM
Will you be releasing your devbuild for 1.4.5 as well?
Kalembas #30
Posted 22 December 2012 - 08:49 AM
I think its time to release a build for 1.4.6 already. Current version works on 1.4.5 just fine. :)/>
infAl #31
Posted 22 December 2012 - 10:14 AM
This issue *should* be fixed in the next release as the issue seems to be the same as the forestry bug. Im going to try and release a new version that fixes this within the next few days.
Awesome! Thanks! :)/>

Will you be releasing your devbuild for 1.4.5 as well?
I think its time to release a build for 1.4.6 already. Current version works on 1.4.5 just fine. :)/>
Doesn't this really just depend on the version of Minecraft that Computer Craft is currently supporting?
someone9999 #32
Posted 22 December 2012 - 11:22 AM
This issue *should* be fixed in the next release as the issue seems to be the same as the forestry bug. Im going to try and release a new version that fixes this within the next few days.
Awesome! Thanks! :)/>

Will you be releasing your devbuild for 1.4.5 as well?
I think its time to release a build for 1.4.6 already. Current version works on 1.4.5 just fine. :)/>
Doesn't this really just depend on the version of Minecraft that Computer Craft is currently supporting?

Pretty much. You can't run it without Computer Craft being updated.

That being said, it takes time for things to be updated as it requires testing to find new bugs that may appear. A good example of this would be when this mod was updated to 1.4.4 / 1.4.5. It was quite rushed in the port to the newer version as real life was getting hectic, and as a result, had some more bugs that the version before it had.


I think its time to release a build for 1.4.6 already. Current version works on 1.4.5 just fine. :)/>
Will you be releasing your devbuild for 1.4.5 as well?

The next release will likely be 1.4.4 / 1.4.5 only. I hope to release for 1.4.6 soon, but I can't make any guarantees.
Marval #33
Posted 25 December 2012 - 04:33 AM
Can't wait for 1.4.6 version. I already have ultimate crafting program which consist of chest and Analitycal Turtle only, and this is only think that keep me in 1.4.5.
necrogami #34
Posted 03 January 2013 - 07:40 AM
Any ETA of this updating? I'm looking forward to playing with this on my 1.4.6/7 instance to make the insanity reactor system.
needoriginalname #35
Posted 03 January 2013 - 08:53 AM
You are a livesaver, I was just about to cancel making my large computercraft program I have been working on, because I didn't relize that the turtles couldn't get the itemID until recently. Granted, since there is no such thing as a wireless Analyitical Crafting Turtle, I am going to have to change my design I bit to make middleman, but I can work with that.
someone9999 #36
Posted 04 January 2013 - 10:33 PM
Sorry about a few days turning into weeks…. but here it is :)/>. Family took over more of my life than expected over the holidays XD.

I decided to release it without adding all the new features that I was planning to, so a lot of stuff is disabled. If you go into the config file, you'll notice that there is some stuff for a "liquid" turtle. Currently, that functionality is disabled as it is too unstable to release that part of this add-on. I am however, releasing all the fixes for the analyzer right now, as well as porting to 1.4.6.

LInk in first post



Any ETA of this updating? I'm looking forward to playing with this on my 1.4.6/7 instance to make the insanity reactor system.

Good luck with the insanity reactor system. That sounds complex o.0.

Can't wait for 1.4.6 version. I already have ultimate crafting program which consist of chest and Analitycal Turtle only, and this is only think that keep me in 1.4.5.

That program sounds awesome! Glad to see that you are enjoying the add-on,
Marval #37
Posted 06 January 2013 - 07:41 AM
Function takeAt() doesn't work… What I'm doing wrong?
http://img341.imageshack.us/img341/8013/20130105194140.png
Ehrlingby #38
Posted 07 January 2013 - 07:56 AM
E
Function takeAt() doesn't work… What I'm doing wrong?
http://img341.images...30105194140.png
I have the exact same problem, bug?
Marval #39
Posted 08 January 2013 - 01:38 AM
It seems to. We only can wait for someone999, I already PM him.
Ehrlingby #40
Posted 08 January 2013 - 04:51 AM
Can someone help us!?
someone9999 #41
Posted 08 January 2013 - 06:22 PM
Function takeAt() doesn't work… What I'm doing wrong?
http://img341.images...30105194140.png
E
Function takeAt() doesn't work… What I'm doing wrong?
http://img341.images...30105194140.png
I have the exact same problem, bug?
It seems to. We only can wait for someone999, I already PM him.
Can someone help us!?

Sorry about that! I'm uploading a new version right now that fixes this issue.

Edit:
2.3 has been uploaded, please use that version instead of 2.2

Sorry for the inconvenience. I'll do my best not to let anything that major slip through again. Thanks to those who posted / PM'd me, as I would not have known about the glitch without those messages.
fomenta #42
Posted 15 January 2013 - 10:56 PM
Created an account just to say this is a wonderful mod. Exactly what we were looking for. Although I disagree, I understand the developers not wanting to include this functionality in the base install – that being said, we found ourselves really wanting a solution like this – thank you.

The mod just works.

The one annoyance I had was that we were getting charged "moves" (fuel) for using analyzer operations. This isn't consistent with the other peripherals (modem, mining, attacking) so it was a bit annoying. However, the mod author gives us the option to disable these costs in the configuration file.

Wonderful job.

PS. I'd be interested in helping with the mod / browsing the source code – if you're hosting your project on a github-type site, I'd be interested in the link. Thanks again.
xInDiGo #43
Posted 25 January 2013 - 06:40 AM
so this is essentially another mod, in addition to computercraft? so a server running this mod would require the client to have this mod too right?
Marval #44
Posted 25 January 2013 - 07:07 AM
Yes of course
Doczott #45
Posted 02 April 2013 - 04:43 AM
Ok. It is not working for me.

My code
Spoilerlocal analyzer = peripheral.wrap("right")
turtle.select(1)
local bn = analyzer.getBlockName()
io.write(bn)
print(analyzer.getBlockId())
print(analyzer.getBlockMetadata())
print(analyzer.getCheckUsesLeft())
print(analyzer.getActionUsesLeft())

and I get the error

test:3: attempt to call nil

What is wrong here?

And yes, I do have Someone9999's mod in my mod list.
electrodude512 #46
Posted 02 April 2013 - 05:32 AM
Ok. It is not working for me.

My code
Spoilerlocal analyzer = peripheral.wrap("right")
turtle.select(1)
local bn = analyzer.getBlockName()
io.write(bn)
print(analyzer.getBlockId())
print(analyzer.getBlockMetadata())
print(analyzer.getCheckUsesLeft())
print(analyzer.getActionUsesLeft())

and I get the error

test:3: attempt to call nil

What is wrong here?

And yes, I do have Someone9999's mod in my mod list.

Is the analyzer on the right or left side of the turtle?

electrodude
Doczott #47
Posted 02 April 2013 - 09:45 AM
Is the analyzer on the right or left side of the turtle?

If I am not mistaken, when you make an analytical turtle, the analyzer is always on the right.
Marval #48
Posted 19 May 2013 - 05:01 PM
Is there any chance to update this mod?