12 posts
Posted 26 July 2013 - 09:54 AM
I'm messing around with tables and am in need of a way to clear an already existing table. Being new to Lua, I can't figure out what to do at this point (Also, what I have already looks so hilariously wrong). Help would be appreciated.
758 posts
Location
Budapest, Hungary
Posted 26 July 2013 - 09:58 AM
If you must keep using the reference the table points to, you'll have to nil every indices of the table:
for key, value in pairs(tbl) do tbl[key] = nil end
If you use the table only for one thing, and the reference is not important, you can just recreate it:
tbl = {}
EDIT: The latter creates a new table right there an then and puts its reference into tbl.
12 posts
Posted 26 July 2013 - 10:17 AM
If you must keep using the reference the table points to, you'll have to nil every indices of the table:
for key, value in pairs(tbl) do tbl[key] = nil end
If you use the table only for one thing, and the reference is not important, you can just recreate it:
tbl = {}
EDIT: The latter creates a new table right there an then and puts its reference into tbl.
Can't believe I didn't think of those haha. Thanks again LBPHacker!