Hi,
I'm writing a program to configure display options automatically. I need help with how I'm organizing my data, and how I'm using it.
The data I'm using is saved in two Lua tables; data for static values, and settings for user configured (can be changed, saved and loaded).
Not all settings are Boolean, I'll come back to this in the second part of the question.
The format is like this:
Declare / Set table data
Now, I'm wanting to execute the changes iteratively:
Currently I have:
Execute change
I've done iteration with key value pairs previously, but that doesn't work for this.
Basically, I'm trying to iterate through the tables ensuring
Part two, some settings and data are drop downs, so I'd need to separate these from the table and place them in their own iteration.
ComboBox Example
I cant currently see a way through it that isnt long winded; add an index to both tables, merge the tables into a fresh table at runtime and iterate through referencing essentially
Or, have I got myself into a cul-de-sac and need to redo the data structures?
If this were another language, I'd approach it using either arrays of objects, or multi-dimensional arrays that can be iterated in a consistent order.
Open to any discussion that will increase my understanding of Lua to solve this problem.
I'm writing a program to configure display options automatically. I need help with how I'm organizing my data, and how I'm using it.
The data I'm using is saved in two Lua tables; data for static values, and settings for user configured (can be changed, saved and loaded).
Not all settings are Boolean, I'll come back to this in the second part of the question.
The format is like this:
Declare / Set table data
Lua:
local data = {}
local settings = {}
settings.showPCNames = {
foreground = true,
background = false
}
settings.showNPCNames = {
foreground = true,
background = false
}
[BGCOLOR=initial]data.showPCNames = {[/BGCOLOR]
window = "OptionsWindow",
child = "ODP_PCNamesCheckBox"
}
data.showNPCNames = {
window = "OptionsWindow",
child = "ODP_NPCNamesCheckBox"
}
Currently I have:
Execute change
Lua:
mq.TLO.Window('OptionsWindow').DoOpen()
if (mq.TLO.Window(data.showPCNames.window).Child(data.showPCNames.child).Checked() ~= settings.showPCNames.foreground) then
mq.TLO.Window(data.showPCNames.window).Child(data.showPCNames.child).LeftMouseUp()
end
Basically, I'm trying to iterate through the tables ensuring
data.value and settings.value are synchronised.Part two, some settings and data are drop downs, so I'd need to separate these from the table and place them in their own iteration.
ComboBox Example
Lua:
settings.loadScreenCombobox = {
foreground = 1,
background = 0
}
data.loadScreenCombobox = {
window = "OptionsWindow",
child = "ODP_LoadScreenCombobox"
}
if (mq.TLO.Window(data.loadScreenCombobox.window).Child(data.loadScreenCombobox.child).GetCurSel() ~= settings.loadScreenCombobox.foreground) then
mq.TLO.Window(data.loadScreenCombobox.window).Child(data.loadScreenCombobox.child).Select(settings.loadScreenCombobox.foreground)
end
this.key.value for each iteration of the code block.Or, have I got myself into a cul-de-sac and need to redo the data structures?
If this were another language, I'd approach it using either arrays of objects, or multi-dimensional arrays that can be iterated in a consistent order.
Open to any discussion that will increase my understanding of Lua to solve this problem.
Last edited:

