Thread Tools Display Modes
12/03/15, 11:26 AM   #1
coolmodi
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 47
Problem adding stats to gamepad UI

Hey,

while adding stats to the gamepad UI stat screen, I encountered an error that I don't understand.
I created the new labels and added the needed variables into ZO_GamepadStats:InitializeCharacterStats():

Lua Code:
  1. local gamepadStatsLC = ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelLeftColumn
  2. local gamepadStatsRC = ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelRightColumn
  3.  
  4. local spellPenHeader = CreateControlFromVirtual("SpellPenetrationHeader", gamepadStatsLC, "ZO_GamepadStatsHeaderTemplate")
  5. spellPenHeader:ClearAnchors()
  6. spellPenHeader:SetAnchor(TOPLEFT, ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelLeftColumnRidingSpeedHeader, BOTTOMLEFT, 0, 90)
  7. local spellPenData = CreateControlFromVirtual("SpellPenetration", gamepadStatsLC, "ZO_GamepadStatsDataTemplate")
  8. spellPenData:ClearAnchors()
  9. spellPenData:SetAnchor(TOPRIGHT, ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelLeftColumnRidingSpeed, BOTTOMRIGHT, 0, 90)
  10. local physPenHeader = CreateControlFromVirtual("PhysicalPenetrationHeader", gamepadStatsRC, "ZO_GamepadStatsHeaderTemplate")
  11. physPenHeader:ClearAnchors()
  12. physPenHeader:SetAnchor(TOPLEFT, ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelRightColumnRidingTrainingHeader, BOTTOMLEFT, 0, 50)
  13. local physPenData = CreateControlFromVirtual("PhysicalPenetration", gamepadStatsRC, "ZO_GamepadStatsDataTemplate")
  14. physPenData:ClearAnchors()
  15. physPenData:SetAnchor(TOPRIGHT, ZO_GamepadStatsTopLevelRightPaneInfoPanelCharacterStatsPanelRightColumnRidingTrainingTimer, BOTTOMRIGHT, 0, 50)
  16.  
  17. local OrigInitializeCharacterStats = ZO_GamepadStats.InitializeCharacterStats
  18. function ZO_GamepadStats:InitializeCharacterStats()
  19.     OrigInitializeCharacterStats(self)
  20.     if MitigationPercent.savedVariables.showPen then
  21.         self.spellPenetrationHeader = spellPenHeader
  22.         self.physicalPenetrationHeader = physPenHeader
  23.         --table.insert(self.headers, { label = self.SpellPenetrationHeader, stat = STAT_SPELL_PENETRATION })
  24.         --table.insert(self.headers, { label = self.PhysicalPenetrationHeader, stat = STAT_PHYSICAL_PENETRATION })
  25.         spellPenHeader:SetText("Focus Rating")
  26.         physPenHeader:SetText("Physical Penetration")
  27.        
  28.         self.physicalPenetration = physPenData
  29.         self.spellPenetration = spellPenData
  30.         table.insert(self.statValues, { label = self.spellPenetration, stat = STAT_SPELL_PENETRATION })
  31.         table.insert(self.statValues, { label = self.physicalPenetration, stat = STAT_PHYSICAL_PENETRATION })
  32.     end
  33. end


The values get updated and it works as it should, but when I add the headers (commented out) too, I get a "attempt to index nil value" error in zo_stats_gamepad.lua line 813:

Lua Code:
  1. header.label:SetText(GetStatText(header.stat))

even if I use a stat that is already in the screen by default that happens. With SetText(as used currently) it works fine though. It's literally the same way I add the values, and they work, why isn't it working for the headers too? Do I miss something obvious?
  Reply With Quote
12/03/15, 06:47 PM   #2
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
I'm away from the game now, but I'm going to take a long a shot here.

Wouldn't 'self.SpellPenetrationHeader' actually just be 'SpellPenetrationHeader'?

Just from looking at it, as I said, I don't know that part of the code.

"attempt to index nil value" is when you try to do something with a table key that doesn't exist.
  Reply With Quote
12/03/15, 11:12 PM   #3
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
It looks like a type-O (capitalization):

Lua Code:
  1. self.spellPenetrationHeader = spellPenHeader
  2. self.physicalPenetrationHeader = physPenHeader
  3. --table.insert(self.headers, { label = self.SpellPenetrationHeader, stat = STAT_SPELL_PENETRATION })
  4. -- Should start with lower case s:
  5. table.insert(self.headers, { label = self.spellPenetrationHeader , stat = STAT_SPELL_PENETRATION })
  6.  
  7. --table.insert(self.headers, { label = self.PhysicalPenetrationHeader, stat = STAT_PHYSICAL_PENETRATION })
  8. -- Should start with lower case p:
  9. table.insert(self.headers, { label = self.physicalPenetrationHeader , stat = STAT_PHYSICAL_PENETRATION })
  Reply With Quote
12/04/15, 07:26 AM   #4
LoveMusique
Join Date: Dec 2015
Posts: 2
Circonian has reason, it's a code like that
  Reply With Quote
12/04/15, 10:21 AM   #5
coolmodi
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 47
Oh god, I feel so stupid now, I even rewrote it multiple times, how did I manage to always write that big without noticing?

Thanks
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Problem adding stats to gamepad UI


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