• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved OTClient mehah, can't make conditions work properly.

ralke

(҂ ͠❛ ෴ ͡❛)ᕤ
Joined
Dec 17, 2011
Messages
1,521
Solutions
27
Reaction score
870
Location
Santiago - Chile
GitHub
ralke23
Twitch
ralke23
Hi! I wonder if someone can help me at this. I have a weird error on conditions, OTClient. I use a custom inventory panel that holds player conditions, buttons, etc. And the toggle function of the condition is not working properly. When I log in PZ for example, it doesn't show the icon of protection zone. But as long I get out, I get the protection zone icon turns on (it's like conditions are reversed).

Without condition icon inside PZ.
1705388117521.png
With condition icon outside PZ
1705388124307.png

As I see the toggle function is wrong onLogin, since the condition is activated as soon is "triggered" instead of when player stands on special tile.
Please give me a hand with this! Here is the functions and I have attached a .rar file with the module.

Lua:
function toggleIcon(bitChanged)
    local content = inventoryWindow:recursiveGetChildById('conditionPanel')

    local icon = content:getChildById(Icons[bitChanged].id)
    if icon then
        icon:destroy()
    else
        icon = loadIcon(bitChanged)
        icon:setParent(content)
    end
end

function loadIcon(bitChanged)
    local icon = g_ui.createWidget('ConditionWidget', content)
    icon:setId(Icons[bitChanged].id)
    icon:setImageSource(Icons[bitChanged].path)
    icon:setTooltip(Icons[bitChanged].tooltip)
    return icon
end

function onStatesChange(localPlayer, now, old)
    if now == old then
        return
    end

    local bitsChanged = bit.bxor(now, old)
    for i = 1, 32 do
        local pow = math.pow(2, i - 1)
        if pow > bitsChanged then
            break
        end
        local bitChanged = bit.band(bitsChanged, pow)
        if bitChanged ~= 0 then
            toggleIcon(bitChanged)
        end
    end
end

Thanks in advance!
Post automatically merged:

After more test found that this only happens with some characters, other characters have their conditions working well. How is this possible? Is this related to cache somehow? Any help is appreciated. Regards!
Post automatically merged:

Fixed! I was missing
Lua:
function offline()
    inventoryWindow:setParent(nil, true)
    inventoryWindow:recursiveGetChildById('conditionPanel'):destroyChildren()
end
 

Attachments

Last edited:
Back
Top