that last part confused me, where assigning a new value to the existing var still returned the old value, but...
I will look into metatables. I haven't worked with them yet. Just to clarify, my issue was with creating new options during development. Say I had
Code:
defaults = {
scale = .9,
fontsize = 14
}
Then, in my PEW function I put
Code:
MYMODDB = MYMODDB or defaults
That would make
Code:
print(MYMODDB.scale)
return .9
After playing with the code for a while, I decide I want to add an alpha option as well. So my defaults table changes to this
Code:
defaults = {
scale = .9,
fontsize = 14,
alpha = .7
}
...
MYMODDB = MYMODDB or defaults
And somewhere in the code I have
Code:
f:SetAlpha(MYMODDB.alpha)
But, upon reloading the UI to pick up the changes made to the lua, I would get an error for
Code:
f:SetAlpha(MYMODDB.alpha)
because
Code:
print(MYMODDB.alpha)
would return nil
I probably didn't need to explain myself, as I'm sure you knew what I meant, and I will read up on metatables.
Thanks, Slakah.