webmcp

view framework/env/slot/reset_all.lua @ 567:5e3ebe9fd0ce

Added tag v2.2.1 for changeset 3b71fdb3a00d
author jbe
date Wed Apr 28 13:07:52 2021 +0200 (2 months ago)
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