35 lines
615 B
Lua
35 lines
615 B
Lua
state = {}
|
|
|
|
function state_init(key)
|
|
if not state[key] then
|
|
state[key] = {}
|
|
end
|
|
end
|
|
|
|
function state_get(key)
|
|
if not state[key] then
|
|
state_init(key)
|
|
end
|
|
return state[key]
|
|
end
|
|
|
|
function state_get_value(key, id)
|
|
if not state[key] then
|
|
return
|
|
end
|
|
local value = state[key]
|
|
for _, it in ipairs(value) do
|
|
if (it.id == id) then
|
|
return it
|
|
end
|
|
end
|
|
end
|
|
|
|
function state_set(key, val)
|
|
if not state[key] then
|
|
state_init(key)
|
|
end
|
|
print_debug("UPDATING STATE FOR " .. key)
|
|
state[key] = val
|
|
return state[key]
|
|
end |