Thread Tools Display Modes
02/23/21, 01:28 PM   #1
mamol27
Join Date: Feb 2021
Posts: 4
How to set action to hotbar

Hi!

I have actionSlotIndex, hotbarCategory, actionType and actionId.
And I need two things: set action to slot in hot bar and get link and icon of this action.
I tried AddHotbarSlotChangeToAllocationRequest but nothing happened.

Can u help me how can I to do it?

Thanks!
  Reply With Quote
02/23/21, 01:37 PM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Check the code of addons which already do change the skills on the actionbars, like AlphaGear2.
Should be something like the function AG.LoadSet which e.g initiates the laoding of a defined set of equipped items and skills, or similar.

It will add something to the internal table AG.Jobs with the type AG.JOB_TYPE_LOAD_SKILL_BAR.
And then somewhere this table AG.Jobs will be parsed, using this type to initiated the skill change on the action bars.
If you search for JOB_TYPE_LOAD_SKILL_BAR you'll see it will be in function AG.HandleOnUpdate()
-> elseif (jobType == AG.JOB_TYPE_LOAD_SKILL_BAR) then
AG.LoadBar(param1)

So AG.LoadBar should handle the skill change

Hope this helps.

Lua Code:
  1. --- returns the abilityIndex for a given abilityId
  2. function AG.GetAbility(abilityId)
  3.     trace ('Searching Ability with ID %d', abilityId)
  4.  
  5.  
  6.     -- local exists = DoesAbilityExist(abilityId)
  7.     -- trace ('Ability exists: %s', tostring(exists))
  8.  
  9.     -- local  texName = GetAbilityIcon(abilityId)
  10.     -- trace ('Ability texture: %s', texName)
  11.  
  12.     -- local st, si, ai, mc, ri = GetSpecificSkillAbilityKeysByAbilityId(abilityId)
  13.     -- trace ('Specific keys: %d, %d, %d, %d', si, ai, mc, ri)
  14.  
  15.     -- Returns: boolean hasProgression, number progressionIndex, number lastRankXp, number nextRankXP, number currentXP, boolean atMorph
  16.     local hasProgression, progressionIndex = GetAbilityProgressionXPInfoFromAbilityId(abilityId)
  17.  
  18.     trace ('Progression Index: %s,  %d', tostring(hasProgression), progressionIndex)
  19.  
  20.     if not hasProgression then
  21.         trace('Ability with ID %d has no progression.', abilityId)
  22.         return 0
  23.     end
  24.  
  25.  
  26.     -- Returns: string name, number morph, number rank
  27.     local _, morph, rank = GetAbilityProgressionInfo(progressionIndex)
  28.  
  29.     -- Returns: string name, string texture, number abilityIndex
  30.     local name, _, abilityIndex = GetAbilityProgressionAbilityInfo(progressionIndex, morph, rank)
  31.     if abilityIndex then
  32.         trace('Found ability %s with Index %d for ID %d.', name, abilityIndex, abilityId)
  33.         return abilityIndex
  34.     else
  35.         trace('Did not find ability with ID %d.', abilityId)
  36.         return 0
  37.     end
  38. end
  39.  
  40. function AG.LoadSkill(nr, slot)
  41.     if not nr or not slot then return end
  42.  
  43.     local skillID = AG.setdata[nr].Skill[slot]
  44.    
  45.     -- TODO remove skill from bar, if set is locked and skillID == 0
  46.     if skillID == 0 then return end
  47.  
  48.     local currentSkillID = GetSlotBoundId(slot+2)
  49.  
  50.     if skillID ~= currentSkillID then
  51.         trace('SkillId in slot %d changed. Current: %d new: %d', slot, currentSkillID, skillID)
  52.         local newAbilityIndex = AG.GetAbility(skillID)
  53.         local currentAbilityIndex = AG.GetAbility(currentSkillID)
  54.  
  55.         if newAbilityIndex ~= 0 and currentAbilityIndex ~= newAbilityIndex then
  56.             trace('AbilityIndex has changed, replacing. Current AI: %d, New AI: %d', currentAbilityIndex, newAbilityIndex)
  57.             local res, msg = CallSecureProtected('SelectSlotAbility', newAbilityIndex, slot+2)
  58.  
  59.             if not res then
  60.                 -- d("|cFF0000Failed to set new skill. Message:|r "..(msg or "<none>"))
  61.                 d("|cFF0000Failed to set new skill due to a bug in ESO.|r Kill a mob and try again!")
  62.             end
  63.         end
  64.     end
  65. end
  66.  
  67. function AG.LoadBar(nr)
  68.     if not nr then return end
  69.     for slot = 1, 6 do AG.LoadSkill(nr,slot) end
  70. end

Last edited by Baertram : 02/23/21 at 01:47 PM.
  Reply With Quote

ESOUI » Developer Discussions » Tutorials & Other Helpful Info » How to set action to hotbar

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off