1

不确定这是否是发布此类问题的地方,我认为需要有人熟悉 TableTop Simulator 游戏才能提供帮助,但我想我会尝试。我正在尝试创建一个脚本,该脚本使用脚本框来检查卡片的描述在该位置,一旦一张新卡片被绘制到 4 个脚本框之一,如果该描述等于“快速”,卡片就会得到移动到第一个盒子,所有之前的卡片都移动超过 1 个盒子。然而,每次第 4 张牌快速移动时,它会读取第 4 张牌两次并将其移动到第一个盒子,然后再回到第 4 个盒子,而不是将第 3 张牌移动到第 4 个盒子。我不明白为什么它会两次获得第四张牌。

fc = 现有卡片数量 + 正在添加的卡片数量

d = nil
fz = 0

function onLoad()
    DeckZone = {getObjectFromGUID('2d5588'), getObjectFromGUID('bf2a55'), getObjectFromGUID('5bdb70'), getObjectFromGUID('d01463')}  -- guid of script boxes with decks in them
    CombatZone = {getObjectFromGUID('2d2792'), getObjectFromGUID('74aafc'), getObjectFromGUID('68ebc9'), getObjectFromGUID('30818f')} -- the guids of the boxes
    Combat = {CombatZone[1].getPosition(),CombatZone[2].getPosition(),CombatZone[3].getPosition(),CombatZone[4].getPosition()} -- the Positions of the boxes

-- Buttons correlating to the decks being pulled from --
        DeckZone[3].createButton({
            click_function="click_drawCombat", function_owner=self, alignment=3,
            position={0, -0.45, 0}, height=450, width=450, font_size=1000, color = {1,1,1,1}, tooltip = "Click to Draw Combat Card."
        })
        DeckZone[4].createButton({
            click_function="click_drawCombat", function_owner=self, alignment=3,
            position={0, -0.45, 0}, height=450, width=450, font_size=1000, color = {1,1,1,1}, tooltip = "Click to Draw Combat Card."
        })
end

function click_drawCombat(obj)
    local deck = obj.getGUID()
    if deck == "5bdb70" then
        d = 3
    elseif deck == "d01463" then
        d = 4
    end
    findDeck()
    if #objects > 0 then
        if type == 'footsoldier' then
            if fz < 4 then
                fz = fz + 1
                table.insert(FSDeckZoneSaved, obj)
                local faceup = {}
                faceup.position = Combat[fz]
                faceup.flip = true
                local pos = Combat[fz]
                for _, obj in ipairs(objects) do
                    globalDeck.takeObject(faceup)
                    Wait.time(function() fastCard(fz) end, 0.3, 1)
                end
            end
        end
    end
end

function findDeck()
    globalDeck = nil
    objects = DeckZone[d].getObjects()
    for i, deck in ipairs(objects) do
        globalDeck = getObjectFromGUID(deck.getGUID())
    end
end

function findCombat()
    globalDeck = nil
    objects = CombatZone[cz].getObjects()
    for i, deck in ipairs(objects) do
        globalDeck = getObjectFromGUID(deck.getGUID())
    end
end

--part that not's working below--

function fastCard(fc)
    cz = fc
    fC = fc
    findCombat()
    fast = globalDeck.getDescription()
    fastCardTest(fc)
end

function fastCardTest(fc)
    if fast ~= 'Fast' or fc == 1 or fc == 5 then
        Wait.time(combatDeckButtons, 1.5, 1)
    end
    if fast == 'Fast' and fc > 1 and fc ~= 5 then
        for t=1,cz do
            if cz == fc then
                findCombat()
                guid = globalDeck.getGUID()
                pos = Combat[1]
                globalDeck.setPositionSmooth(pos, false, false)
            end
            if cz ~= fc then
                findCombat()
                pos = Combat[cz+1]
                globalDeck.setPositionSmooth(pos, false, false)
            end
            cz = cz - 1
        end
        Wait.time(combatDeckButtons, 1.5, 1)
    end
end
4

0 回答 0