ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Lua/XML Help (https://www.esoui.com/forums/forumdisplay.php?f=175)
-   -   Referencing values in list? (https://www.esoui.com/forums/showthread.php?t=6517)

ArtOfShred 09/14/16 08:32 PM

Referencing values in list?
 
I'm having an issue with this segment of code I'm adding for LUIE's buff tracker.

Currently, I'm adding a fake buff tracking component to track abilities with no active effect applied on the player:

Right now, in its current form I'm using 3 variables to discern information and fill the fields for each buff created. This all works just fine, but I have to list the ability ID under 3 separate lists for this to function:


I want to just consolidate it to one entry for each ability, so I made this list:


And tried to reference the values here:


However when I attempt to reference the values in the list I'm getting an error that it's returning a nil value for each of these lines:
iconName = FakeBuffs[abilityId].icon
effectName = FakeBuffs[abilityId].name
duration = FakeBuffs[abilityId].duration
I'm pretty new to LUA: Am I just messing up the syntax here or misunderstanding it entirely?

Scootworks 09/14/16 09:12 PM

i'm not a coder, but i have some ideas:
- hamstring is an example or a real buff Name? if it's a real buffname, please don't hardcode the Name
- s'rendarr used this for fake stuff:

fake procs:
Code:

local fakeProcs = {
        [21230] = {unitTag = 'player', duration = 5, icon = '/esoui/art/icons/ability_rogue_006.dds'},
}

and the name for the procs:
Code:

local procAbilityNames = {
        [GetAbilityName(21230)] = false,

fake auras:
Code:

local fakeAuras = {
        [GetAbilityName(23634)] = {unitTag = 'groundaoe', duration = 18, abilityID = 200000},
}

maybe this could help you?

Sasky 09/14/16 11:01 PM

Quote:

Originally Posted by ArtOfShred (Post 28354)
However when I attempt to reference the values in the list I'm getting an error that it's returning a nil value for each of these lines:
iconName = FakeBuffs[abilityId].icon
effectName = FakeBuffs[abilityId].name
duration = FakeBuffs[abilityId].duration
I'm pretty new to LUA: Am I just messing up the syntax here or misunderstanding it entirely?

What's most likely happening is that FakeBuffs[abilityId] doesn't exist. So then on those particular lines it tries to dereference nil.

You need something more like:

Lua Code:
  1. function SCB.OnCombatEvent( ... )
  2.     if FakeBuffs[abilityId] ~= nil then
  3.         iconName = FakeBuffs[abilityId].icon
  4.         effectName = FakeBuffs[abilityId].name
  5.         duration = FakeBuffs[abilityId].duration
  6.  
  7.         ...
  8.     end
  9. end

PS - use the Lua BBCode when posting code snippets -- not screenshots

ArtOfShred 09/15/16 05:01 AM

Quote:

Originally Posted by Scootworks (Post 28355)
i'm not a coder, but i have some ideas:
- hamstring is an example or a real buff Name? if it's a real buffname, please don't hardcode the Name
- s'rendarr used this for fake stuff:

So hamstrung is the debuff in question, it's a 5 sec snare applied randomly by NPC's if the player is moving (I think with their back turned primarily). It normally has no aura display associated with it. I overwrote the name for the debuff as "Hamstring" because I don't like the past tense there. I've added the functionality to overwrite names for situations like that as well as various stun effects present in quests with names like "CON_Knockback&Knockdown" that don't have a display. Instead I'd rename it to something appropriate for the situation. A good example is: 39579: CON_Knockback&Knockdown, a 2 sec stun that is applied when the player gets hit by Palolel's Rage, a knockback + stun ability used by Queen Palolel in the 3rd Fighter's Guild Quest. It would be silly to have the mouseover name for that ability remain unchanged, renaming it to "Palolel's Rage" or just "Stun" would be more appropriate.

Quote:

Originally Posted by Sasky (Post 28356)
What's most likely happening is that FakeBuffs[abilityId] doesn't exist. So then on those particular lines it tries to dereference nil.

You need something more like:

Lua Code:
  1. function SCB.OnCombatEvent( ... )
  2.     if FakeBuffs[abilityId] ~= nil then
  3.         iconName = FakeBuffs[abilityId].icon
  4.         effectName = FakeBuffs[abilityId].name
  5.         duration = FakeBuffs[abilityId].duration
  6.  
  7.         ...
  8.     end
  9. end

PS - use the Lua BBCode when posting code snippets -- not screenshots

Ah that did the trick, thanks! Ends up my duration formatting was off as well, but now it's working perfectly. Thanks for your aid!


All times are GMT -6. The time now is 12:11 AM.

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