-
Автор темы
- #1
вроде всё в конфиг дате вписано, а выдает nil value. как решить?
[neverlose] ["script"]:1441: attempt to index a nil value
stack traceback:
["script"]:1441: in function 'load' (
if (k == 'bools') then
cfg.data[k][k2]:set(v2)
end
)
["script"]:1490: in function <["script"]:1489> (
var.import:set_callback(function()
cfg.load(cfglib[1].get())
end)
)
[neverlose] ["script"]:1441: attempt to index a nil value
stack traceback:
["script"]:1441: in function 'load' (
if (k == 'bools') then
cfg.data[k][k2]:set(v2)
end
)
["script"]:1490: in function <["script"]:1489> (
var.import:set_callback(function()
cfg.load(cfglib[1].get())
end)
)
Код:
cfg = {}
cfg.data = {
bools = {
var.indicators,
},
ints = {
--тут билдер
},
floats = {
var.aspectratio_value,
},
strings = {
var.wm_text
},
colors = {
var.widgets_color,
}
}
local cfglib = { require('neverlose/clipboard'), require('neverlose/base64') }
cfg.load = function(text)
local decode_cfg = json.parse(cfglib[2].decode(text))
for k, v in pairs(decode_cfg) do
k = ({[1] = 'bools', [2] = 'ints', [3] = 'floats', [4] = 'strings', [5] = 'colors'})[k]
for k2, v2 in pairs(v) do
if (k == 'bools') then
cfg.data[k][k2]:set(v2)
end
if (k == 'ints') then
cfg.data[k][k2]:set(v2)
end
if (k == 'floats') then
cfg.data[k][k2]:set(v2)
end
if (k == 'strings') then
cfg.data[k][k2]:set(v2)
end
if (k == 'colors') then
cfg.data[k][k2]:set(color(tonumber('0x'..v2:sub(1, 2)), tonumber('0x'..v2:sub(3, 4)), tonumber('0x'..v2:sub(5, 6)), tonumber('0x'..v2:sub(7, 8))))
end
end
end
end
var.import:set_callback(function()
cfg.load(cfglib[1].get())
end)