Access window object via dynamic var naming
Afternoon Folks,
Another one that's getting to me.
Code:
for _,v in pairs(savedDiceRoll) do
i = i + 1;
if i == 1 then
setDiceIcons(["dice" .. 1], v)
elseif i == 2 then
setDiceIcons(dice2, v)
elseif i == 3 then
setDiceIcons(dice3, v)
elseif i == 4 then
setDiceIcons(dice4, v)
elseif i == 5 then
setDiceIcons(dice5, v)
elseif i == 6 then
setDiceIcons(dice6, v)
elseif i == 7 then
setDiceIcons(dice7, v)
elseif i == 8 then
setDiceIcons(dice8, v)
elseif i == 9 then
setDiceIcons(dice9, v)
elseif i == 10 then
setDiceIcons(dice10, v)
else
end
end
That code is quite crude, but I cannot figure out a way to dynamically access an in window control. This window has '10' dice controls and I'm trying to change their icons (to match the original dice rolls). It's all working if I do it long-handed, but there must be an easier way (like in the setDiceIcons(["dice" .. 1], v) which'd work in JS etc).
Any thoughts on how to do this would be ace!
Cheers,
MBM