East98
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 418 |
|
|
| 26 Jul 2017 02:27 PM |
Is it possible? For example lets say youre iterating over a table which contains only tables which contain data and you want to remove one. It would be set up something like this:
for at,tab in pairs(tables) do if invalid(tab) --[[Function which decides if the table should stay--]] then remove(tables,at) end end
However this would not work because after you remove the first table, the ordereing of the tables after will be thrown off. (Say you remove the table at position 2, Now the tables that was at position 3 shifts to position 2 and now if you try to remove the table at position 3 youre actually removing the table that was at position 4)
Hope this is making sense...
I realize you could iterate the tables backwards starting with the highest index and checking if the table is valid but youd still be using the table.remove() function. Im not that familiar with metatables and metafunctions but is there some way you could rig that up so that if you call a metafunction it 'destroys' its parent table?
--East98 |
|
|
| Report Abuse |
|
|
| |
|
East98
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 418 |
|
|
| 26 Jul 2017 02:36 PM |
| But the table is still there... That wouldnt remove it, it would jut change it to a blank table |
|
|
| Report Abuse |
|
|
LaeMVP
|
  |
| Joined: 24 Jun 2013 |
| Total Posts: 4416 |
|
| |
|
|
| 26 Jul 2017 02:38 PM |
I thought you didn't want to remove it because it would offset everything
Maybe I just didn't read the whole post |
|
|
| Report Abuse |
|
|
East98
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 418 |
|
|
| 26 Jul 2017 02:41 PM |
| Yeah probly just bad wording on my part... I guess the problem lies more in the way i iterate the table. Im trying to run a segment of code once for every table within the table and if a value a table is false, delete the table from the bigger one. |
|
|
| Report Abuse |
|
|