Logistics Pipes

Logistics Pipes

13M Downloads

CC API - Crafting/Request Interface

Flow86 opened this issue ยท 2 comments

commented

Hi,

the "craft only request" works fine, but sometimes it would be cool to have the possibility to test "how much could I craft?"

it would be nice if the makeRequest-function would return the amount possible and not only "MISSING" or a option "request/craft as much as you can" (this option would sometimes be useful for the gui-requester too)

commented

5428a7f makes it possible to get the result of the request (good or bad) like this:

crafting pipe behind computer

p = peripheral.wrap("back")

doCrafting = true

if doCrafting then
    print("Using Crafting")
    items = p.getCraftableItems()
else
    print("Using Provider")
    items = p.getAvailableItems()
end

for nr,item in ipairs(items) do
    if doCrafting then
        itemId = item
        itemCount = 1
    else
        itemId = item[1]
        itemCount = item[2]
    end

    name = p.getUnlocalizedName(itemId)

    print(itemId, ": ", p.getItemID(itemId), "#", p.getItemDamage(itemId), " = ", name, ": ", itemCount)

    result = p.makeRequest(itemId, itemCount, doCrafting)

    print(result[1])                     -- DONE/MISSING/NO_POWER
    for nr,item in ipairs(result[2]) do  -- the List of items requested/missing in the same list-format as getAvailableItems.
        print(p.getUnlocalizedName(item[1]), ": ", item[2])
    end

    print("")
    print("")
end

you can either set "doCrafting" to true or false

WARNING!!!! IT WILL REQUEST ALL ITEMS AVAILABLE!!!! SO ONLY USE IT FOR TESTING IN A SMALL NETWORK!!!

crafting
provider

commented

hmm okay, the missing information still doesnt show me "you cant request XX items, only YY" but I think its a step in the right direction already