webmcp

view framework/env/slot/reset_all.lua @ 441:839ff2b8d9f8

Bugfix for integer decoder in JSON library
author jbe
date Sat Feb 13 19:47:58 2016 +0100 (2016-02-13)
parents f491011ebe16
children
line source
1 --[[--
2 slot.reset_all{
3 except = except -- Reset all slots, except slots named in this list
4 }
6 Calling this function resets all slots to be empty. An exclusion list may be passed to the function as named argument.
8 --]]--
10 local data_metatable = {}
11 function data_metatable:__index(key)
12 self[key] = { string_fragments = {}, state_table = {} }
13 return self[key]
14 end
16 function slot.reset_all(args)
17 local saved
18 if args and args.except then
19 saved = {}
20 for i, key in ipairs(args.except) do
21 saved[key] = slot._data[key]
22 end
23 end
24 slot._data = setmetatable({}, data_metatable)
25 if saved then
26 for key, value in pairs(saved) do
27 slot._data[key] = value
28 end
29 end
30 end

Impressum / About Us