Thread Tools Display Modes
05/29/15, 09:38 PM   #1
hoydyd
Join Date: May 2015
Posts: 7
Question regarding getchildren()

Hi

I recently began learning lua and how to create addons, and have been having trouble with handling children of a ui element. I am trying to call a function on the children of ZO_CompassFrame, and rather than individually calling a function on each child, i thought i would do so through a for loop ( for k,v in pairs(ZO_CompassFrame:getchildren()) do v:function() ). I can use values from a list of numbers such as getdimensions(), however when trying to get the list of children through getchildren(), the game gives the 'expected function instead of nil stack traceback' error. I believe it is something to do with the list containing objects(?), as lists containing strings and integers etc work fine. I am new to lua, so am i just missing something?

Thanks
  Reply With Quote
05/30/15, 02:19 AM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Hi

I recently began learning lua and how to create addons, and have been having trouble with handling children of a ui element. I am trying to call a function on the children of ZO_CompassFrame, and rather than individually calling a function on each child, i thought i would do so through a for loop ( for k,v in pairs(ZO_CompassFrame:getchildren()) do v:function() ). I can use values from a list of numbers such as getdimensions(), however when trying to get the list of children through getchildren(), the game gives the 'expected function instead of nil stack traceback' error. I believe it is something to do with the list containing objects(?), as lists containing strings and integers etc work fine. I am new to lua, so am i just missing something?

Thanks
Common to all controls is just GetNumChildren() and GetChild(index)
So, the code from above should be:
Lua Code:
  1. for index = 1, ZO_CompassFrame:GetNumChildren() do
  2.   ZO_CompassFrame:GetChild(index):function()
  3. end

You may take a look to Ayantir's super collection of Dev Tools to see available functions.
  Reply With Quote
05/30/15, 03:39 AM   #3
hoydyd
Join Date: May 2015
Posts: 7
Originally Posted by votan View Post
Common to all controls is just GetNumChildren() and GetChild(index)
So, the code from above should be:
Lua Code:
  1. for index = 1, ZO_CompassFrame:GetNumChildren() do
  2.   ZO_CompassFrame:GetChild(index):function()
  3. end

You may take a look to Ayantir's super collection of Dev Tools to see available functions.
Thank you very much!

Just out of curiosity, why is it that the method i was trying to do doesn't work? Is it due to the way the game API works?
  Reply With Quote
05/30/15, 04:11 AM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Thank you very much!

Just out of curiosity, why is it that the method i was trying to do doesn't work? Is it due to the way the game API works?
Yes. ZO_CompassFrame does not have GetChildren().
ZO_SceneGraphNode and ZO_TreeNode are the only "classes" having such a member. (As far as I could see)
  Reply With Quote
05/30/15, 03:30 PM   #5
hoydyd
Join Date: May 2015
Posts: 7
Originally Posted by votan View Post
Yes. ZO_CompassFrame does not have GetChildren().
ZO_SceneGraphNode and ZO_TreeNode are the only "classes" having such a member. (As far as I could see)
Oh, Zgoo had it listed as a function under ZO_CompassFrame. Atleast I can use the other method you described. Thank you for your help votan
  Reply With Quote
05/30/15, 03:56 PM   #6
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by hoydyd View Post
Oh, Zgoo had it listed as a function under ZO_CompassFrame. Atleast I can use the other method you described. Thank you for your help votan
GetChildren is introduced by zgoo after using it
Not fair from zgoo
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Question regarding getchildren()


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