badspacebar / sdk

6 stars 3 forks source link

How to loop buffs #16

Closed 69sinisterblade69 closed 1 year ago

69sinisterblade69 commented 1 year ago

How to check all buffs of object? Documentation says to not use buffManager in favor of obj.buff, but I don't see any way to do that. What's the correct way to do something like that?

for i = 0, obj.buffManager.count - 1 do
    buff = obj.buffManager:get(i)
    if buff and buff.valid then 
        print("Owner: "..obj.charName.." Name: "..buff.name.." Stacks: "..buff.stacks)
    end
end
badspacebar commented 1 year ago
    local x = 100
    local y = 100

    graphics.draw_text_2D("stacks", 14, x, y - 24, 0xFFFFFFFF)
    graphics.draw_text_2D("counter", 14, x + 50, y - 24, 0xFFFFFFFF)
    graphics.draw_text_2D("startTime", 14, x + 100, y - 24, 0xFFFFFFFF)
    graphics.draw_text_2D("buff", 14, x + 300, y - 24, 0xFFFFFFFF)

    local buff_keys = player.buff.keys
    for i = 1, buff_keys.n do
        local buff_key = buff_keys[i]
        local buff = player.buff[buff_key]

        graphics.draw_text_2D(tostring(buff.stacks), 14, x, y, 0xFFFFFFFF)
        graphics.draw_text_2D(tostring(buff.stacks2), 14, x + 50, y, 0xFFFFFFFF)
        graphics.draw_text_2D(tostring(buff.startTime), 14, x + 100, y, 0xFFFFFFFF)
        graphics.draw_text_2D(tostring(buff.name), 14, x + 300, y, 0xFFFFFFFF)

        if string.find(buff.name, 'charge') then
            --print(buff.name)
        end

        y = y + 24
    end