Thread Tools Display Modes
04/20/15, 10:28 PM   #1
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
ScrollList not displaying data...

This feels like one of those mysterious undocumented language failures that just doesn't work in ZOS's LUA implementation and fails without warning or error.

I have a ScrollList that I populate with data when I click some navigation buttons, and this works fine.

I try and populate the same list from another function and it fails without error, displaying nothing.

What is odd is if I print the data strings I am pushing to the datalist table they all show up correctly formatted just like the data lists I push from the buttons that work.

There is literally no reason this shouldn't work, and yet, it doesn't.

Is there some undocumented failure with ScrollLists?
  Reply With Quote
04/20/15, 10:33 PM   #2
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Works:

Code:
function PLD.ScrollList(list)
	ZO_ScrollList_Clear(MainFrameListFrameList)
    local datalist = ZO_ScrollList_GetDataList(MainFrameListFrameList)
	local known
	local nametable
	local listsize = PLD.TableSize(nametable, list)
	for i = 1, listsize do
		local level = nametable[i].Level
		local saved = PLDGetTierSavedVar(i, list, 0)
		if IsItemLinkRecipeKnown(nametable[i].Link) == false then
			if saved == 1 then
				known = "|cffffff[s] |r"
			elseif saved == 0 then
				known = "|cc3c3c3[  ] |r"
			end
		else
			known = "|cffff00[*] |r"
		end
		datalist[i] = ZO_ScrollList_CreateDataEntry( 1, 
		{
			RecipeName = known .. "|c3a92ff" .. nametable[i].Name .. "|r" .. "|cffffff " .. level .. "|r",
		}
		)
	end
	ZO_ScrollList_Commit(MainFrameListFrameList, datalist)
end
Doesn't work:
Code:
function PLD.Test()
	ZO_ScrollList_Clear(MainFrameListFrameList)
    local datalist = ZO_ScrollList_GetDataList(MainFrameListFrameList)
	local known
	local searchtext = MainFrameSelectionFrameSearchBox:GetText():gsub('%W',''):lower()
	for i = 1, 486 do
		local name = ProvisioningLabels[i].Name:gsub('%W',''):lower()
		if (string.find(name,searchtext) ~= nil) then
			local ln = tonumber(ProvisioningLabels[i].Position)
			local level = ProvisioningLabels[ln].Level
			local saved = PLDGetTierSavedVar(i, 15, ln)			
			if IsItemLinkRecipeKnown(ProvisioningLinks[ln].Link) == false then
				if saved == 1 then
					known = "|cffffff[s] |r"
				elseif saved == 0 then
					known = "|cc3c3c3[  ] |r"
				end
			else
				known = "|cffff00[*] |r"
			end
			datalist[i] = ZO_ScrollList_CreateDataEntry( 1, 
			{
				RecipeName = known .. "|c3a92ff" .. ProvisioningLabels[ln].Name .. "|r" .. "|cffffff " .. level .. "|r",
			}
			)
		end
	end
	ZO_ScrollList_Commit(MainFrameListFrameList, datalist)
end

No errors, just fails to populate the list. Debug text shows all values are correct.
INFURIATING.
  Reply With Quote
04/21/15, 02:18 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
In the working code the index counter i of datalist is continous, while in the not working code, datalist could have gaps, because some values of i are not inserted to datalist.
Try to use a new index counter: datalist[rowNumber] instead using i. or table.insert
  Reply With Quote
04/21/15, 08:51 AM   #4
Phinix
 
Phinix's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 186
Originally Posted by votan View Post
In the working code the index counter i of datalist is continous, while in the not working code, datalist could have gaps, because some values of i are not inserted to datalist.
Try to use a new index counter: datalist[rowNumber] instead using i. or table.insert
Wow, you're a life saver man!

I created a new local variable in the main function and iterated it + 1 for each match and used that as the datalist index and it is working like a charm.

:cheers:
  Reply With Quote
04/21/15, 09:18 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,991
If you are using integer index for the tables you could just use the function
table.insert(tableName, value).
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » ScrollList not displaying data...


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