Quantcast
Weird For loop question - ESOUI
Thread Tools Display Modes
10/03/21, 10:31 AM   #1
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 21
Weird For loop question

Hi there,
is there a way to do a for loop to do this :

ZO_WorldMapContainer1:setSomething(thing)
ZO_WorldMapContainer2:setSomething(thing)
ZO_WorldMapContainer3:setSomething(thing)
etc...
Vvardenfell has 81 WorldMapContainers !
  Reply With Quote
10/03/21, 10:40 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,753
Is there a parent of the world map containers? e.g. is ZO_WorldMapContainer the parent of ZO_WorldMapContainer1?

Then do:
Lua Code:
  1. local numChildren = <parentOfWorldmapContainers>:GetNumChildren()
  2. for i=1, numChildren, 1 do
  3.  local childOfParent = <parentOfWorldmapContainers>:GetChild(i)
  4.  childOfParent:setSomething(thing)
  5. end

Else do it like this:

Lua Code:
  1. local numWorldMapContainers = 81 --maybe there is a better way to ge the 81 dynamically from the active map's ID or similar?
  2. local templateName = "ZO_WorldMapContainer"
  3. local WM = WINDOW_MANAGER
  4. for i=1, numWorldMapContainers , 1 do
  5.  local worldMapContainer = WM:GetControlByName(templateName , i) --Will create a control with name "ZO_WorldMapContainer1" and so on
  6.  worldMapContainer :setSomething(thing)
  7. end


If you describe here (https://gitter.im/esoui/esoui) what you want to achieve I bet there will be even an easier/better way that devs like votan (who got a good knowledge of the worldmaps) can hep you with.

Last edited by Baertram : 10/03/21 at 10:44 AM.
  Reply With Quote
10/03/21, 12:25 PM   #3
Masteroshi430
 
Masteroshi430's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2020
Posts: 21
Ah thanks a lot !
I'm not familiar the parent / child concept , I will study it

The second example works without exceptions, apparently the number of WorldMapContainers & tiles are the same so we can do that to get the total number in the map:

Lua Code:
  1. local numHorizontalTiles, numVerticalTiles = GetMapNumTiles()
  2. local numWorldMapContainers = numHorizontalTiles * numVerticalTiles
  Reply With Quote
10/04/21, 01:07 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,753
You can use the addon merTorchbug or zgoo to inspect the control below your mouse ingame.
e.g. type /tbm or /zgoo mouse into the chat box and press the return key.

An inspector should open showing you the contents of the control, like the name, some attributes like hidden (which relates to IsHidden() return value) and others.
At the bottom (at least with merTorchbug) you can see the headline "Children" or "Childs" where you can see a list of the children of that parent.
At the top you cans ee the parent and owningWindow of the control itsself.
You can click the chilrden to open an inspector for them as well.

The __index is showing the metatables of the control/object/variable so that you can see where it comes/inherits from and what functions/Attributes are given (like a combobox control inherits from ZO_ComboBox "class" and the base class got some functions that can be used on the combobox control then as well).
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Weird For loop question

Thread Tools
Display Modes

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