Hi,
I’m fairly new to tables, having trouble locating the shortcut for batch assignment of a custom property.
Table contains abbreviations for each US state …
local states = { ak, al, ar ... wy }
--Looking for a way to batch the following table-wide declaration/assignment
states.[every element].is\_State = true;
--Each state also has custom 'label' property declared outside { } like this
ak.label = akL;
…
wy.label = wyL;
Sample usage in a touch-check function …
local labelMatch; --holds var for current answer (i.e., akL)
for i = localGroup[i]numChildren, 1, -1 do
if localGroup[i].is\_State then --if touch is within a state
if localGroup[i].label == labelMatch then --if label matches
transition.to(localGroup[i], {time=1000, alpha=1}); -- fade in state
end)
end
end
Typing 50 ‘is_State’ declarations works, but seems insanely inefficient, given that all elements share the same property and value; and, there are other cases where identical set-wide property values apply.
Is it possible to batch assign? Does calling these, as above, require any special syntax?
If you know how to do this or where to find the doc, I’d greatly appreciate any help you can give. I’m having trouble translating table examples that I’ve found to this case. Thanks very much.
Best,
Lynne [import]uid: 11631 topic_id: 33547 reply_id: 333547[/import]