Advertisement
Rochet2

Untitled

Aug 6th, 2015
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. local meta = {}
  2. meta.__index = meta
  3. local T = setmetatable({}, meta) -- T is the actual table you use
  4.  
  5.  
  6. T[asd] = 5 -- new change gets saved inside T
  7.  
  8.  
  9. func OnSave()
  10.     local meta = getmetatable(T)
  11.     local keystodel = {}
  12.     for k,v in pairs(T) do -- save the data and move it to metatable
  13.        Save(k, v)
  14.        meta[k] = v
  15.        table.insert(keystodel, k)
  16.     end
  17.     for k,v in ipairs(keystodel) do -- not to confuse above loop saved all keys to a table and now deleting them
  18.        T[v] = nil
  19.     end
  20.    
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement