From de15c25defbe04041b3146fa808eb01772729f8b Mon Sep 17 00:00:00 2001 From: bol-van Date: Tue, 25 Nov 2025 13:03:11 +0300 Subject: [PATCH] zapret-antidpi: luaexec --- lua/zapret-antidpi.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lua/zapret-antidpi.lua b/lua/zapret-antidpi.lua index 4de6724..3fc7950 100644 --- a/lua/zapret-antidpi.lua +++ b/lua/zapret-antidpi.lua @@ -70,6 +70,23 @@ standard ipfrag : ]] +-- execute given lua code. "desync" is temporary set as global var to be accessible to the code +-- useful for simple fast actions without writing a func +-- arg: code= +function luaexec(ctx, desync) + if not desync.arg.code then + error("luaexec: no 'code' parameter") + end + local fname = desync.func_instance.."_luaexec_code" + if not _G[fname] then + _G[fname] = loadstring(desync.arg.code, fname) + end + -- allow dynamic code to access desync + _G.desync = desync + _G[fname]() + _G.desync = nil +end + -- dummy test function. does nothing. -- no args function pass(ctx, desync)