Thread Tools Display Modes
09/14/16, 08:32 PM   #1
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
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?
  Reply With Quote
09/14/16, 09:12 PM   #2
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 312
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?
  Reply With Quote
09/14/16, 11:01 PM   #3
Sasky
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 231
Originally Posted by ArtOfShred View Post
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
  Reply With Quote
09/15/16, 05:01 AM   #4
ArtOfShred
 
ArtOfShred's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 103
Originally Posted by Scootworks View Post
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.

Originally Posted by Sasky View Post
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!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Referencing values in list?


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