From 38e63b9ecee03fa68f792eadaac9c24c4a182848 Mon Sep 17 00:00:00 2001 From: rubin Date: Mon, 23 Jan 2023 23:06:43 +0300 Subject: [PATCH] added many object levels for utf8_function --- TruckHUD.lua | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/TruckHUD.lua b/TruckHUD.lua index dcc1de4..d7cd333 100644 --- a/TruckHUD.lua +++ b/TruckHUD.lua @@ -4578,7 +4578,7 @@ script_update = { function utf8_function(utf8_func, in_encoding, out_encoding) for i = 1, #utf8_func do if _G[utf8_func[i][1]] ~= nil then - local new_function = function(...) + utf8_function_create = function(...) local pack = table.pack(...) for i = 1, pack.n do if type(pack[i]) == "string" then @@ -4593,13 +4593,14 @@ function utf8_function(utf8_func, in_encoding, out_encoding) end return table.unpack(result) end - if #utf8_func[i] == 1 then - utf8_func[i][1000] = _G[utf8_func[i][1]] - _G[utf8_func[i][1]] = new_function - else - utf8_func[i][1000] = _G[utf8_func[i][1]][utf8_func[i][2]] - _G[utf8_func[i][1]][utf8_func[i][2]] = new_function + local text = "_G" + for s = 1, #utf8_func[i] do + text = string.format('%s["%s"]', text, utf8_func[i][s]) end + text = string.format('%s = _G["utf8_function_create"];', text) + utf8_func[i][1000] = _G[utf8_func[i][1]] + load(text)() + _G["utf8_function_create"] = nil end end end