How do you loop k,v pairs to create fontstrings?
Similar to this
Lua Code:
But how do you do it for a table constructed like this Lua Code:
So that when looped the fontstring comes out like this? entry One entry2 Two entry3 Three Thanks in advance :) Edit: This is the method I found that works, if anyone knows a better way I'm all ears :D Lua Code:
I have this in a function a button calls so 'i' always starts as 1 |
I think you'd be better explaining more of what you are wanting to do with the fontstrings after they are created. From what you've posted it seems like you are thinking you have to create a new frontstring every time you want to display something different whereas you only need to create a fonstring once and there after, just change the text it displays.
eg. Lua Code:
|
Quote:
|
You can't pre-determine the order of a table using strings as keys. You could do something like:
Lua Code:
|
This is all I wanted
Lua Code:
Click the "G" button and the data is presented. |
This has both problems I described.
Every time you press the G button you are creating a new set of fonstrings on top of the previous set of fontstring. Because you've been lucky with the display order doesn't mean you will continue to be lucky if you change or extend the table entries: The offsetting is to display what's happening if you press the G button multiple times Lua Code:
|
Thanks, I noticed the constant creation of entries as well when clicking and shall look over your code to make sense of it lol :D
|
It's just saving a list of already created fontstrings into the f2.Fonstrings table as {left, right} pairs and re-using them if they exist or creating additional if required. It's just a demonstration so it's not handling things like hiding fonststrings if subsequent clicks contain a shorter list etc.
This would really be better as a scroll list if you're likely to have more entries than you can display vertically in the frame. This contains a link in the OP to one way this might work. |
All times are GMT -6. The time now is 12:30 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI