This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

dynamic name for a table
#5
(21.12.2025, 11:37)admin Wrote:
Code:
t = {}
for i = 1, 10 do
  t[ i ] = {}
end

log(t[ 2 ])

Thanks but I don't explain myself very well, this my situation:
I have
name = {'Tv_1','Tv_2','Tv_3'}
number_entry = 3
entry = {[1] = {['component'] = 'switch'}, [2] = {['component'] = 'audioVolume'}, [3] = {['component'] = 'audioMute'}}

result must be a table as this: 

new = {{[Tv_1] = {['component'] = 'switch',['component'] = 'audioVolume',['component'] = 'audioMute'}, [Tv_2] = {['component'] = 'switch',['component'] = 'audioVolume',['component'] = 'audioMute'}, [Tv_3] = {['component'] = 'switch',['component'] = 'audioVolume',['component'] = 'audioMute'}}

in this way in a second part of script when I will call 

object = new.Tv_1[1] I will give switch

Best regards Cristian
Reply


Messages In This Thread
dynamic name for a table - by CristianAgata - 21.12.2025, 11:05
RE: dynamic name for a table - by admin - 21.12.2025, 11:07
RE: dynamic name for a table - by admin - 21.12.2025, 11:37
RE: dynamic name for a table - by CristianAgata - 21.12.2025, 13:13
RE: dynamic name for a table - by admin - Yesterday, 06:18

Forum Jump: