From c211da3c9013028c740f47e3dfa3b3c8de659984 Mon Sep 17 00:00:00 2001 From: bufan <821869798@qq.com> Date: Wed, 7 Jun 2023 22:41:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0lua=E9=A2=84=E5=A4=84?= =?UTF-8?q?=E7=90=86=E7=9A=84=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/conf/config.toml | 2 +- .../TablePreProcess/global_postprocess.lua | 17 +++++++++++++++++ .../TablePreProcess/preprocess_complex_test.lua | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 examples/tools/LuaProject/TablePreProcess/global_postprocess.lua create mode 100644 examples/tools/LuaProject/TablePreProcess/preprocess_complex_test.lua diff --git a/examples/conf/config.toml b/examples/conf/config.toml index 004617b..025ab01 100644 --- a/examples/conf/config.toml +++ b/examples/conf/config.toml @@ -35,7 +35,7 @@ gen_dir = "./temp_meta" post_process = true #导出配置的后处理开关 temp_dir = "./temp_work/temp_lua" post_process_lua = "./tools/DataTableOptimizer.lua" - post_work_dir = "./" + post_work_dir = "./tools" lua_win_dir = "./tools/lua5.3/lua53.exe" lua_mac_dir = "./tools/lua5.3/lua53" diff --git a/examples/tools/LuaProject/TablePreProcess/global_postprocess.lua b/examples/tools/LuaProject/TablePreProcess/global_postprocess.lua new file mode 100644 index 0000000..ed7ebfd --- /dev/null +++ b/examples/tools/LuaProject/TablePreProcess/global_postprocess.lua @@ -0,0 +1,17 @@ + + + +local TablePostProcess = {} + +---@class global_postprocess +--全局配置后处理,在所有配置预处理之后 +local function global_postprocess(database) + --处理校验或者其他逻辑 + + + --也可以删除包内不要的表,database.xx = nil即可(相当于仅做预处理) + +end + + +return global_postprocess \ No newline at end of file diff --git a/examples/tools/LuaProject/TablePreProcess/preprocess_complex_test.lua b/examples/tools/LuaProject/TablePreProcess/preprocess_complex_test.lua new file mode 100644 index 0000000..504e655 --- /dev/null +++ b/examples/tools/LuaProject/TablePreProcess/preprocess_complex_test.lua @@ -0,0 +1,15 @@ + +local function preprocess_complex_test(data_table) + for k1,v1 in pairs(data_table) do + for k2,v2 in pairs(v1) do + v2.number = v2.number + 1 + end + end + + --双key结构开启这个才能支持默认值metatable + data_table.__isdoublekeydata = true + + return data_table +end + +return preprocess_complex_test \ No newline at end of file