I have several tables/variables (sampled below):
mytable = { ['100'] = { ['2']=0,['3']=0,['5']=0,['6']=0,['7']=0,['9']=0},
['101'] = { ['8']={['81']=0,['86']=0},
['13']={['81']=0},
['30']={['81']=0,['82']=0,['83']=0,['84']=0,['85']=0} },
['102'] = { ['81']={['location']='left',['3']=1} }
}
mytable2 = 5
I need a function to pass a table/variable structured like one of the two above (could be either one) that will differentiate between current and previous data, and return a table/variable that only consists of the data that has changed since last called per client (a unique ID passed with the table/variable). The tables can grow or change between execution of the function.
So if the following updates occurred between execution of the function:
mytable['101']['8']['81']=1
mytable['102']['81']['4']=0
the function would return
mytable = { ['101'] = { ['8']={['81']=1} },
['102'] = { ['81']={['4']=0} }
}
Although this adds empty keys, I think it will work for me:
UPDATED to handle second case and remove unnecessary lines related to get and set metatable…
UPDATED again to handle null previous tables.