Logistics Pipes

Logistics Pipes

13M Downloads

CC API: Available ComputerCraft methods

btbenedi opened this issue ยท 11 comments

commented

Mod Versions:
CC 1.65
LP 0.8.3.95 (FTB Infinity, I also put in 0.8.3.100 for completeness, no difference)
OpenPeripheral-1.7.10-AIO-1 (saw in the past that OP had conflicts, but I don't think that's the issue here)

Unless I'm missing something major, I'm not seeing all the methods necessary to call 'makeRequest' with ComputerCraft.

image

'makeRequest' requires ItemIdentifierID correct? if so, how do I get that?

Also, not sure if it pertains, because I don't think 'makeRequest' uses actual item ids, but if you try makeRequest(1,1) it returns 'Java exception thrown'

If the API for CC is working correctly and I'm just missing something here, I would be more than happy to help contribute to the Wiki on the CC API page with these methods

'getAvailableItems' also appears to not be returning correctly:

image

p = peripheral.wrap("right")

items = p.getAvailableItems()

for nr,item in ipairs(items) do
    itemId = item[1]
    itemCount = item[2]
    print("test")
    print(itemId, ": ", itemId)
    print("test2")
end

image

Holy wall of information, sorry if it's overkill, let me know if you need anything else.

commented

Im Sure your NEI will show you the IDs, both numerical and, via an ingame option, the Unique Identifier

commented

I thought I had tried 'makeRequest("minecraft:stone",1)' and I still got the java exception error, but I can try it again

commented

This is all I get, if I look in the FTB Console, on "Minimal","Extended", or "Debug" there is nothing output there besides the InventoryTweaks line when I open up the computer GUI

image

commented

Making some progress here, if I use this code, it does output the stone from getAvailableItems

If I try to use peripheral.call for makeRequest I still get the Java exception thrown message from above

Got it! If I use the ItemIdentifier table for stone that getAvailableItems returns, then I can use makeRequest

Going to take some unusally long peripheral code. But I think it is working, would be nice if we didn't have to use peripheral.call for this though. Nvm :)

commented

You both asume that makeRequest and getAvailableItems is based on ID's, which it is not.

LP uses an ItemIdentifier Object (not ID) to identify the items. That way we can handle ItemID, MetaData and NBTTagInformation. In order to get an Identifier Object without using the Available Items, you can you the lp object.
lp = pipe.getLP() should return it. It is an global object, the same on every computer and every pipe. You can see what it can do with lp.help(). There should be an ItemIdentifier builder command in there. That should give you an ItemIdenitfierBuilder Object. If you then set the Id and meta data on that object (use .help() on the builder) you can then call .build() on the builder and it should return the ItemIdentifier which you can use in makeRequest.
As for the getAvailableItems() result. It also is constructed out of ItemIdentifier which are contained in LP_Pairs. Again use .help() on them to see all available commands. (And if IIRC you should be able to print() the objects to see what kind of object they are)

commented

can you give us report stacktrace of the Exception youre getting?

commented

Ok thank you, I knew there was an ItemIdentifier object, as well as I saw something about the Builder, just couldn't find documentation on how to get it.

If I figure it all out, I may go and edit the wiki for the API.

Thanks for the help, this can be closed. If someone is reading this in the future, Go here hopefully I'll have updated that to have more documentation.

commented

@btbenedi I can give you access to the wiki, if you send me an email on [email protected]
Registration is closed, because of spam bots.

commented

@davboecki this itemidentifier object is quite nice, however usually some ItemID is enough. Why do you not publish some easier APIs too to access items in LP via classical ID and let this ItemIdentifierObject thing used in difficult situations?

commented

Because that would mean more work to handle everything while the methods needed for the ItemIdentifierObject handling can be done trough our Computer interaction framework and don't need do be special handled.

commented

I see and accept your opinion.