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

How to get ItemIdentifier ID in Logistics Pipes?

Started by Xnihil0, 21 May 2016 - 02:45 AM
Xnihil0 #1
Posted 21 May 2016 - 04:45 AM
In a search for an auto crafting solution, I think mini-Logistics Pipes networks that connect to my AE system will work better that simply an AE system because they have native integration with ComputerCraft, while Applied Energistics only has underutilized OpenPeripheral support. However there's still minimal documentation and a lot of it appears to be outdated (the LP Wiki, for example.)

Here's my end goal:

Occasionally, probably with sleep function, the computer will call on the logistics pipes system to see how much of a certain item there is. If that item is below a certain threshold, math will occur and and the materials necessary to craft more of the item will be requested. Since Logistics Pipe can recognize AE items through an ME interface, I believe the materials can be called and requested fairly easily, once I solve my main problem. The requested items would then be fed into a machine to process and craft the item to replenish the storage system. For example, if I decide to make 10 reinforced Thermal Expansion machines and suddenly my supply of 100 hardened glass has diminished to 60. The next time the computer calls it will find the quantity of Hardened Glass is below 100, it will request Pulverized Obsidian and Lead and will craft more in one of two ways: Option 1 is easier and is to craft a standardized amount (50) at a time. This is good because it's easier for my not-good-programmer brain but not good because it's possible to take 2 sets of request to refill to above 100, unless I craft an extra 100 at a time. Option 2 is to use some math to figure out a perfect number to reach a maximum threshold of, say, 150.

But all that's only useful in my head because I cannot figure out how to find the ItemIdentifier Objects used by Logistics Pipes. This Github post, specifically the reply by davboecki, seems to have the most information I can find, but I'm not following/understanding what he's saying to do. I'm sure part of it is me doing something wrong and the other is me not understanding it, but I would greatly appreciate it if someone would be able to help me figure out what he's saying. I have wrapped the Request pipe (lp = peripheral.wrap("back")) and looked through all three pages of the lp.help() but could not find anything concerning an "Itemidentifier builder". The closest I've gotten was the following:


lp = peripheral.wrap("back")
print(lp.getLP())

which returned "LP Global Access [table: 2e4748fd]" but I don't know what that means, if it's useful, or what I could do with it.

I'm digging programming but am getting somewhat frustrated with the quirks of Lua and the lack of documentation of Computercraft. I'm pushing through, largely thanks to this and other forums, and enjoying it, but any help possible would be very appreciated.
The Higher Realm #2
Posted 21 May 2016 - 05:30 AM
I have no idea if this is correct (Haven't used Logistic Pipes and CC together) but try doing


lp = peripheral.wrap("back")
var1, var2 = lpgetLP())
print(var1)
print(var2)

That might print out more information. "table:
" means there is more than one variable so maybe var1 and var2 will give you more stuff.
Edited on 21 May 2016 - 03:30 AM
KingofGamesYami #3
Posted 21 May 2016 - 02:00 PM
lack of documentation of Computercraft

ComputerCraft actually has excellent documentation, for everything it (natively) supports. Other mods control the documentation for their peripheral methods, not CC.

Ignore Actaquack322's answer, as it is totally wrong. He has no idea what to do.

I have no idea what the Logistics Pipe people were thinking with their CC interface, it's extremely over complicated and irritating to use. I'm going to need you to do a lot of testing yourself, as I don't have logistics pipes and don't plan on installing it myself.

Now, according to the comment, the stuff printed by lp.getLP() is exactly what I would expect. It's a table, you can't print tables. So, you should iterate through it to get a list of keys and / or values, like this:

for k, v in pairs( lp.getLP() ) do
  print( k .. ": " .. type( v ) )
end

I expect it's full of functions. Please post the output of that program and I can try to help you more from there.
Bomb Bloke #4
Posted 21 May 2016 - 02:18 PM
You'll find pretty much every ComputerCraft-specific function documented here. Very nearly all the rest is standard to Lua 5.1. Mind you, the functions relating to Applied Energistics aren't a part of ComputerCraft, as such (even if they add functionality to ComputerCraft) - I can't speak for them.

You might also find textutils.seralise() handy when you want to view table content. This guide is furthermore well worth a read - if you understand tables and how to traverse their contents, you'll have very little trouble figuring out peripheral mods of any kind.
Edited on 21 May 2016 - 12:20 PM
Xnihil0 #5
Posted 21 May 2016 - 04:17 PM
ComputerCraft actually has excellent documentation, for everything it (natively) supports. Other mods control the documentation for their peripheral methods, not CC.

Yes, you're right. It's not accurate to say ComputerCraft itself doesn't have good documentation.



Here is the output of your code:

identify:function
commandHelp:function
help:function
getType:function
getItemIdentifierBuilder:function

I still don't understand what I can do with the getItemIdentifierBuilder function (although it's pretty clearly what I need to progress). Everything I tried to do with it returns "attempt to call nil."


Also thank you Bomb Bloke.
KingofGamesYami #6
Posted 21 May 2016 - 04:21 PM
What does this give you?


local result = lp.getLP().getItemIdentifierBuilder()
print( type( result ) )
if type( result ) == "table" then
  for k, v in pairs( result ) do
    print( k .. ": " .. type( v ) )
  end
end
Xnihil0 #7
Posted 21 May 2016 - 04:56 PM
Thanks for helping me out on this.

Your code returns:

table
getItemID:function
commandHelp:function
help:function
matchingNBTIdentifier:function
build:function
setItemData:function
getItemData:function
getType:function
setItemID:function
KingofGamesYami #8
Posted 21 May 2016 - 05:22 PM
It would seem likely that you could then do this:


local result = lp.getLP().getItemIdentifierBuilder()
result.setItemID( <minecraft item id> )
local itemIdentifier = result.build()
print( type( itemIdentifier ) )
if type( itemIdentifier ) == "table" then
  for k, v in pairs( itemIdentifier ) do
    print( k .. ": " .. type( v ) )
  end
end

Obviously, you should replace <minecraft item id> with the actual id number (or string, depending on version)
Xnihil0 #9
Posted 21 May 2016 - 05:50 PM
Your code only prints another table of functions, not the Item Identifier ID.

table
commandHelp:function
getID:function
getUndamaged:function
isFluidContainer:function
getName:function
help:function
hasTagCompound:function
getTagCompound:function
getModName:function
isDamageable:function
getType:function
getData:function
getFluidContainer:function
makeStack:function
getIgnoringNBT:function
KingofGamesYami #10
Posted 21 May 2016 - 06:18 PM
That table of functions is actually an object (an "ItemIdentifier Object") According to this comment, that table is what "makeRequest" and "getAvailableItems" use, as opposed to an ID.
Requesting an item would look like this:

local function easyRequest( itemID, amount )
  local result = lp.getLP().getItemIdentifierBuilder()
  result.setItemID( itemID )
  lp.makeRequest( result.build(), amount )
end
easyRequest( "minecraft:stone", 1 )
Edited on 21 May 2016 - 04:19 PM
Xnihil0 #11
Posted 22 May 2016 - 03:10 PM
It works! Thank you very, very, much. I can tell I have a lot to learn but your assistance has taught me a lot and also sets me on the right track to finishing my project in my world.

Regards,
Tomoli75 #12
Posted 06 May 2018 - 10:43 AM
Sorry for bringing back an old post, but can this be modified to accept item damage values?
SquidDev #13
Posted 08 May 2018 - 08:19 AM
Sorry for bringing back an old post, but can this be modified to accept item damage values?
It appears you can use result.setItemData( <damage> ) to filter on damage values too. However I don't think it supports damage values of 0, that will match all items.