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

logistic pipe inventory

Started by Caleb Ragnarok, 29 September 2015 - 05:14 PM
Caleb Ragnarok #1
Posted 29 September 2015 - 07:14 PM
I'm trying to display all the inventory that I have in my logistic pipe network.

When I try to .getAvailableItems(), I get
table: 4386bcfb

When I try .getAvailableItems{}, I get a java error.
java.lang.RuntimeException: Took too long

What I want to do, is get the available items I have stored, and then display the item name and amount on a monitor.

I only have at the momment two items in the system and both are under 300 in count
Edited on 29 September 2015 - 05:15 PM
valithor #2
Posted 29 September 2015 - 07:51 PM
What do these print: (p) is the name of the peripheral


for k,v in pairs(p.getAvailableItems()) do
  print(k)
end


for k,v in pairs(p.getAvailableItems()) do
  print(v)
end

I have never actually used computercraft and logisitics pipes, but I would assume the keys are the names of the items, and the values are the amounts.
Edited on 29 September 2015 - 05:52 PM
Caleb Ragnarok #3
Posted 29 September 2015 - 08:26 PM
k displays a 1 and 2. Considering there are only two items in the system, I'm say these are the two items. v displays anouther table, so I'm thinking the k is the item number in the inventory, and v is the item ID and the how many are in the system.

I had to to do it as,
pipe = peripheral.wrap("left")

for k.v in pairs(pipe.getAvailableItems()) do
print(k, v)
end

If I do just the v, I get an error
'=' or 'in' expected
Edited on 29 September 2015 - 06:29 PM
valithor #4
Posted 29 September 2015 - 08:41 PM
Lets just test to see what the second table has, so:


local pipe = peripheral.wrap("left")

for k,v in pairs(pipe.getAvailableItems()) do
  for key, value in pairs(v) do
    print(key.." "..value)
  end
end
TYKUHN2 #5
Posted 29 September 2015 - 08:44 PM

for k,v in pairs(pipe.getAvailableItems()) do
	print("First: "..k.." Second: "..textutils.serialise(v))
end

Very useful debug data. Valithor I am surprised you didn't ask for that! :)/>
Edited on 29 September 2015 - 07:01 PM
Caleb Ragnarok #6
Posted 29 September 2015 - 09:30 PM
I get an error

attempt to concatenate string and function

on Tyk's example I get an error as well
Cannot serialize type function
valithor #7
Posted 29 September 2015 - 09:43 PM

for k,v in pairs(pipe.getAvailableItems()) do
	print("First: "..k.." Second: "..textutils.serialise(v))
end

Very useful debug data. Valithor I am surprised you didn't ask for that! :)/>

It is essentially what I asked for, but just in a different way :P/>

I get an error

attempt to concatenate string and function

on Tyk's example I get an error as well
Cannot serialize type function

Just know that since I have never used logistics pipes I am just trying to get enough information to help for now :P/>

Okay so in the second table the value is a function and the key is the name of the function, so that means we just need to print the names of the functions. Hopefully one of them will be something we can use to determine what is in the network.


local pipe = peripheral.wrap("left")

for k,v in pairs(pipe.getAvailableItems()) do
  for key, value in pairs(v) do
	print(key)
  end
end

edit:

I am not 100% certain it is even possible to do what you are wanting. If logistics pipes have their own inbuilt CC api then it probably will be, but if the functions are from open peripherals, then it might not.
Edited on 29 September 2015 - 08:00 PM
TYKUHN2 #8
Posted 29 September 2015 - 09:50 PM
I'll duck out considering I am surprised to see item information stored in a function instead of a table.
Caleb Ragnarok #9
Posted 29 September 2015 - 11:00 PM
I do have openperipherals installed. Logistic pipe does have its own API. http://rs485.network/wiki/ComputerCraft_API

I'll try that when I get home.
Caleb Ragnarok #10
Posted 30 September 2015 - 12:29 AM
I get the following
getValue1
getType
commandHelp
help
getType2
getType1
getValue2
getValue1
getType
commandHelp
help
getType2
getType1
getValue2

I've been reading that in older versions, open peripherals interfere with the logistic pipe API. so for the time being, I'm going to take out open peripherals. I tried the work around that was suggested; putting the pipe IDs in the ignore option of open peripherals. I get the same thing.

edit…
I'm going to add a third item to the inventory and see if we get a getType3 and getValue3. I'm thinking the getType(x) is the item ID and the getValue(x) is the amount of the item in storage.

I get another instance of
getType2
getType1
getValue1
getValue2
getType
commandHelp
help


So I guess there is one set of these values for each item.
Edited on 29 September 2015 - 11:12 PM
Caleb Ragnarok #11
Posted 30 September 2015 - 05:37 AM
I checked the keys. all but getValue2 and getType have a function as their output. the output changes after the computer resets.
Edited on 30 September 2015 - 03:44 AM