local table_map = function (t, f)
local res = { };
for k, v in pairs(t) do
local new_k, new_v = f(k, v);
res[new_k] = new_v;
end
return res;
end
local create_listable_handler = function (listable_item)
local listable_item_status = { };
listable_item:set_callback(function (this)
local element_list = this:get_list();
local element_value = this:get();
local active = table_map(element_value, function (k, v)
return v, true;
end);
for i, res in ipairs(element_list) do
listable_item_status[
res
] = active[i];
end
end, true) -- true, чтобы вызвать при запуске скрипта
return listable_item_status;
end
-- example
local indicators_status = create_listable_handler(indicators_listable);
offset_y:depend(function ()
return indicators_status['Doubletap'];
end);
local function on_render(...)
if indicators_status['Dormant'] then
render.text(...);
end
end