ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   way to purchase skillpoints? (https://www.esoui.com/forums/showthread.php?t=10285)

tim99 07/25/22 08:15 AM

way to purchase skillpoints?
 
Hi,
does anyone knows if there is a API for purchasing/spending skillpoints?


Just found things to allocate them to the actionbar after you purchased them, but not for purchasing in the first place.
For example on a new toon to spend the 3 skillpoints on the first skill of each of the 3 class skill lines.

Baertram 07/25/22 09:26 AM

Addons like Caro's Skill and Champion Points Saver should have code to do so, if you want to have a look. But maybe I'm wrong and it just assigns the already purchased skills to the action slots.


If I find the API functions (if they exist, maybe it's the SKILLS_DATA_MANAGER or similar with functions which is able to assign the points) I'll add them here.

Edit:
At the addon compatibility there exists this function, which uses the SKILLS_DATA_MANAGER
https://github.com/esoui/esoui/blob/...iases.lua#L680

Code:

function ZO_Skills_PurchaseAbility(skillType, skillLineIndex, skillIndex)
    local skillData = SKILLS_DATA_MANAGER:GetSkillDataByIndices(skillType, skillLineIndex, skillIndex)
    if skillData then
        skillData:GetPointAllocator():Purchase()
    end
end

function ZO_Skills_UpgradeAbility(skillType, skillLineIndex, skillIndex)
    local skillData = SKILLS_DATA_MANAGER:GetSkillDataByIndices(skillType, skillLineIndex, skillIndex)
    if skillData then
        skillData:GetPointAllocator():IncreaseRank()
    end
end

function ZO_Skills_MorphAbility(progressionIndex, morphSlot)
    local skillType, skillLineIndex, skillIndex = GetSkillAbilityIndicesFromProgressionIndex(progressionIndex)
    local skillData = SKILLS_DATA_MANAGER:GetSkillDataByIndices(skillType, skillLineIndex, skillIndex)
    if skillData then
        skillData:GetPointAllocator():Morph(morphSlot)
    end
end

Better use the SKILLS_DATA_MANAGER directly instead of using those ZO_Skills_* functions, maybe these addon compatibility aliases will be gone one day!

tim99 07/25/22 09:55 AM

awesome, it works. thx very much!!


btw do they really remove aliases from time to time? whats the point in adding aliases when they get removed later anyway? then they can remove it right away as well when it changes...?

Baertram 07/25/22 10:18 AM

Yes they did but not that much yet.
If one sees what the alias does it's a good way to use the "new code" instead of sticking with the old one.

The aliases are only there to make older addons not break, as they used the old exisitng functions and code.
But new addons should not use them anymore and adopt to the same way like vanilla code does it.


All times are GMT -6. The time now is 07:32 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI