21.12.2025, 18:05
(21.12.2025, 13:13)CristianAgata Wrote:Hi, after several test I have found this solution. Do you think could works?(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
Code:
name = {'Tv_1','Tv_2','Tv_3'}
entry = {[1] = {['component'] = 'switch'}, [2] = {['component'] = 'audioVolume'}, [3] = {['component'] = 'audioMute'}}
new_t = {}
for _,value in ipairs(name) do
new_t[value] = {}
table.insert(new_t[value], entry)
end
--storage.set('my_new_table', new_t)
log(new_t['Tv_1'][1][1])
