reobf / Programmable-Hatches-Mod

An addon for GTNH modpack(2.5.1+)
MIT License
38 stars 2 forks source link

io枢纽 dropIntoSlot 失灵 #51

Closed P0lar1z2 closed 1 month ago

P0lar1z2 commented 1 month ago
--function(sourceSide:number, sinkSide:number[, count:number[, sourceSlot:number[, sinkSlot:number]]]):number -- Transfer some items between two inventories.
local function passItem(address)
    local hub = component.proxy(address)
    hub.select(1)
    local item = hub.getStackInInternalSlot(1)
    print("item: " .. item.name)
    local res = hub.dropIntoSlot(1, 1, 1)
    print("passItem: " .. tostring(res))
end

上面放箱子那个是 我通过遍历所有iohub slot1选中 image image 里面有个泥土

后续测试 image

local function passItem(address)
    local hub = component.proxy(address)
    hub.select(1)
    local item = hub.getStackInInternalSlot(1)
    print("item: " .. item.name)
    for i = 0, 5 do
        for j = 0, 5 do
            local res,s = hub.dropIntoSlot(i, 1, 1, j)
            print(i..j,s)
            -- print("passItem: " .. tostring(res))
            if res then
                -- return
                print("passItem: " .. tostring(res))
            end
        end
    end
end

我看代码里的这个函数比官方的多一个参数

P0lar1z2 commented 1 month ago

https://ocdoc.cil.li/api:robot

reobf commented 1 month ago

应该修了https://github.com/reobf/Programmable-Hatches-Mod/releases/tag/v0.0.18p6-beta dropIntoSlot第四个可选参数是GTNH版的OC特供版,robot本身的dropIntoSlot就是四参的,我照搬过去的,确实和wiki不完全一致 问题出于在我没弄清OC的API的格子是从1开始计数的 所以槽位差了一格

OC是scala写的,我不太熟悉这个语言,可能还有其它问题,请见谅

P0lar1z2 commented 1 month ago

修复了 大佬很强了,我不怎么写java要不然可以尝试pull request