### Example Output of Generated Resource List Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Shows the format of the generated resources.txt file. Each line contains the resource tag (e.g., 'item') and its corresponding path, separated by a comma. ```Text item,/ui/icon1.jpg item,/ui/icon2.jpg ``` -------------------------------- ### Generate Unified Resource List from Configuration Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line example to generate a list of all resource addresses tagged in the configuration. The `--output:data:resource_list_file` parameter specifies the output file name. ```Shell --gen_types data_resources --output:data:resource_list_file resources.txt ``` -------------------------------- ### Generate Client Code and Data (Bin Format) with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/commandtools Command-line example to generate client-side code and data in binary format using Luban. It specifies input/output directories, `code_cs_unity_bin` and `data_bin` gen_types, and targets the 'client' service group, including test data. ```Batch dotnet d:\\tools\\Luban.Client\\Luban.Client.dll ^ -h 127.0.0.1 ^ -p 8899 ^ -j cfg ^ -- ^ --define_file d:\\raw_config\\defines\\__root__.xml ^ --input_data_dir d:\\raw_configs\\datas ^ --output_code_dir d:\\client\\Assets\\Gen ^ --output_data_dir d:\\client\\Assets\\StreamingAssets\\GameData ^ --gen_types code_cs_unity_bin,data_bin ^ --service client ``` -------------------------------- ### Load Protobuf2 Binary Data in C# Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Demonstrates how to parse and load binary data generated with Protobuf2 format into a C# object, using the `ParseFrom` method from the generated parser class. ```C# var tbItem = ItemTbItem.Parser.ParseFrom(File.OpenRead("pb_datas/item_tbitem.bytes")); ``` -------------------------------- ### Generate Server Code and Data (JSON Format) with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/commandtools Command-line example to generate server-side code and data in JSON format using Luban. It specifies input/output directories, `code_cs_json` and `data_json` gen_types, targets the 'server' service group, and includes test data. ```Batch dotnet d:\\tools\\Luban.Client\\Luban.Client.dll ^ -h 127.0.0.1 ^ -p 8899 ^ -j cfg ^ -- ^ --define_file d:\\raw_config\\defines\\__root__.xml ^ --input_data_dir d:\\raw_configs\\datas ^ --output_code_dir d:\\server\\src\\Gen ^ --output_data_dir d:\\server\\GameData ^ --gen_types code_cs_json,data_json ^ --service server ``` -------------------------------- ### Lua Data Example for DemoType2 Source: https://luban.doc.code-philosophy.com/docs/help/faq/manual/otherdatasource Demonstrates DemoType2 data representation in Lua. It shows the return statement for loading, set and map syntax, and the _type_ property for polymorphic beans. ```Lua return { x1 = false, x2 = 2, x3 = 128, x4 = 1122, x5 = 112233445566, x6 = 1.3, x7 = 1122, x10 = "yf", x12 = {x1=1}, x13 = "D", x14 = { _type_="DemoD2", x1 = 1, x2=3}, t1 = "1970-01-01 00:00:00", k1 = {1,2}, k2 = {2,3}, k8 = {[2]=10,[3]=12}, k9 = { {y1=1,y2=true}, {y1=10,y2=false} }, k15 = { { _type_="DemoD2", x1 = 1, x2=3} }, } ``` -------------------------------- ### Configure C# Vector Types for Unity Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line option to change the generated C# vector types from `System.Numerics.Vector` to `UnityEngine.Vector` for better compatibility with Unity projects. ```Shell --cs:use_unity_vector ``` -------------------------------- ### Example YAML Data Configuration for Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/datasource This YAML snippet provides an example of data configuration for Luban, showcasing various data types such as boolean, integer, float, string, nested objects, lists, and polymorphic bean types using the '$type' property. ```YAML x1: true x2: 3 x3: 128 x4: 40 x5: 11223344 x6: 1.2 x7: 1.23432 x10: hq x12: x1: 10 x13: B x14: $type: DemoD2 x1: 1 x2: 2 s1: key: "/key32" text: aabbcc22 v2: x: 1 y: 2 v3: x: 1.1 y: 2.2 z: 3.4 v4: x: 10.1 y: 11.2 z: 12.3 w: 13.4 t1: '1970-01-01 00:00:00' k1: - 1 - 2 k2: - 2 - 3 k8: - - 2 - 2 - - 4 - 10 k9: - y1: 1 y2: true - y1: 2 y2: false k15: - $type: DemoD2 x1: 1 x2: 2 ``` -------------------------------- ### Generate Unity C# Binaries with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/commandtools Example command to generate C# code and binary data for Unity projects using Luban. This script configures the workspace, Luban DLL path, and data table root, then executes Luban with specific code and data targets, output directories, path validation, and localization settings. ```Batch set WORKSPACE=..\.. set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll set CONF_ROOT=%WORKSPACE%\DataTables dotnet %LUBAN_DLL% ^ -t all ^ -c cs-bin ^ -d bin ^ --conf %CONF_ROOT%\luban.conf ^ -x outputCodeDir=Assets/Gen ^ -x outputDataDir=..\GenerateDatas\bytes ^ -x pathValidator.rootDir=%WORKSPACE%\Projects\Csharp_Unity_bin ^ -x l10n.textProviderFile=*@%WORKSPACE%\DataTables\Datas\l10n\texts.json ``` -------------------------------- ### Generate Dotnet C# Binaries with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/commandtools Example command to generate C# code and binary data for .NET projects using Luban. This script configures the workspace, Luban DLL path, and data table root, then executes Luban with specific code and data targets, output directories, path validation, and localization settings. ```Batch set WORKSPACE=..\.. set LUBAN_DLL=%WORKSPACE%\Tools\Luban\Luban.dll set CONF_ROOT=%WORKSPACE%\DataTables dotnet %LUBAN_DLL% ^ -t all ^ -c cs-bin ^ -d bin ^ --conf %CONF_ROOT%\luban.conf ^ -x outputCodeDir=Gen ^ -x outputDataDir=..\GenerateDatas\bytes ^ -x pathValidator.rootDir=%WORKSPACE%\Projects\Csharp_Unity_bin ^ -x l10n.textProviderFile=*@%WORKSPACE%\DataTables\Datas\l10n\texts.json ``` -------------------------------- ### Generate Client Code and Data (JSON Format, Exclude Tags) with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/commandtools Command-line example to generate client-side code and data in JSON format using Luban. It specifies input/output directories, `code_cs_unity_json` and `data_json` gen_types, targets the 'client' service group, and excludes data with 'dev' and 'test' tags. ```Batch dotnet d:\\tools\\Luban.Client\\Luban.Client.dll ^ -h 127.0.0.1 ^ -p 8899 ^ -j cfg ^ -- ^ --define_file d:\\raw_config\\defines\\__root__.xml ^ --input_data_dir d:\\raw_configs\\datas ^ --output_code_dir d:\\client\\Assets\\Gen ^ --output_data_dir d:\\client\\Assets\\StreamingAssets\\GameData ^ --gen_types code_cs_unity_json,data_json ^ --service client ^ --export_exclude_tags dev,test ``` -------------------------------- ### Generate Unity C# JSON Data with Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/commandtools Example command to generate C# code and JSON data for Unity projects using Luban. This script sets up the environment variables and then runs Luban to produce C# code and JSON data, specifying output paths and localization file. ```Batch set WORKSPACE=..\.. set GEN_CLIENT=%WORKSPACE%\Tools\Luban\Luban.dll set CONF_ROOT=%WORKSPACE%\DataTables dotnet %GEN_CLIENT% ^ -t all ^ -c cs-simple-json ^ -d json ^ --conf %CONF_ROOT%\luban.conf ^ -x outputCodeDir=Assets/Gen ^ -x outputDataDir=..\GenerateDatas\json ^ -x pathValidator.rootDir=D:\workspace2\luban_examples\Projects\Csharp_Unity_bin ^ -x l10n.textProviderFile=*@D:\workspace2\luban_examples\DataTables\Datas\l10n\texts.json ``` -------------------------------- ### JSON Data Example for DemoType2 Source: https://luban.doc.code-philosophy.com/docs/help/faq/manual/otherdatasource Illustrates how to represent DemoType2 data in JSON. Special considerations for set, map, and polymorphic bean types are shown, including the use of $type for polymorphism. ```JSON { "x1":true, "x2":3, "x3":128, "x4":1, "x5":11223344, "x6":1.2, "x7":1.23432, "x10":"hq", "x12": { "x1":10}, "x13":"B", "x14":{"$type": "DemoD2", "x1":1, "x2":2}, "t1":"1970-01-01 00:00:00", "k1":[1,2], "k2":[2,3], "k7":[2,3], "k8":[[2,2],[4,10]], "k9":[{"y1":1, "y2":true},{"y1":2, "y2":false}], "k15":[{"_type_": "DemoD2", "x1":1, "x2":2}] } ``` -------------------------------- ### YAML Data Format Example Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/otherdatasource Illustrates a sample YAML data structure, highlighting its similarity to JSON and demonstrating set, map, and polymorphic bean type representations. It shows how various data types and complex structures are defined in YAML. ```YAML x1: true x2: 3 x3: 128 x4: 40 x5: 11223344 x6: 1.2 x7: 1.23432 x10: hq x12: x1: 10 x13: B x14: $type: DemoD2 x1: 1 x2: 2 t1: '1970-01-01 00:00:00' k1: - 1 - 2 k2: - 2 - 3 k8: - - 2 - 2 - - 4 - 10 k9: - y1: 1 y2: true - y1: 2 y2: false k15: - $type: DemoD2 x1: 1 x2: 2 ``` -------------------------------- ### Generate Only Data for JSON Format Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line option to generate only the data files in JSON format, excluding code generation. ```Shell --gen_types data_json ``` -------------------------------- ### XML Enum Definition and Attributes Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/define Describes the `enum` definition for creating enumerations. It provides examples of basic and flagged enums, detailing attributes for the enum itself and for individual `var` (enum item) elements. ```XML ``` ```APIDOC enum.name: Required. Enum name. Namespace is the full namespace of the current module (including parent modules). enum.flags: Optional. Whether it's a bit flag type. Defaults to false. If 1 or true, allows READ|WRITE syntax in configuration data. enum.tags: Optional. Tags. Format: "key1=value2#key2=value2#...". Typically used with custom template generation. enum.unique: Optional. Whether enum values are unique. Defaults to true. enum.comment: Optional. Comment. If not empty, included in generated code. enum.var.name: Required. Enum item name. enum.var.alias: Optional. Alias. For planners to fill data, convenient for those less familiar with English. enum.var.value: Optional. Enum value. If empty, value is previous item's value + 1. If first item, value is 0. enum.var.tags: Optional. Tags. Typically used with custom template generation. enum.var.comment: Optional. Comment. If not empty, included when generating enum items. If empty and alias is defined, alias will be used as comment. ``` -------------------------------- ### Example Lua Data Configuration for Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/datasource This Lua snippet illustrates how data is structured for Luban, including boolean, integer, float, string, text tables, nested tables, set-like tables, map-like tables with arbitrary keys, and polymorphic bean types using the '_type_' property. Note the 'return' keyword at the beginning. ```Lua return { x1 = false, x2 = 2, x3 = 128, x4 = 1122, x5 = 112233445566, x6 = 1.3, x7 = 1122, x10 = "yf", t1 = {key="/key/ab1", text="apple"}, x12 = {x1=1}, x13 = "D", x14 = { _type_="DemoD2", x1 = 1, x2=3}, v2 = {x= 1,y = 2}, v3 = {x=0.1, y= 0.2,z=0.3}, v4 = {x=1,y=2,z=3.5,w=4}, t1 = "1970-01-01 00:00:00", k1 = {1,2}, k2 = {2,3}, k8 = {[2]=10,[3]=12}, k9 = { {y1=1,y2=true}, {y1=10,y2=false} }, k15 = { { _type_="DemoD2", x1 = 1, x2=3} }, } ``` -------------------------------- ### Manually Specify Output Data File Extension Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line option to override the default file extension for generated data files, allowing users to set a custom suffix. ```Shell --data_file_extension xxx ``` -------------------------------- ### Example XML Data Configuration for Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/datasource This XML snippet shows how data can be represented for Luban, including basic types, nested elements, and arrays. It also demonstrates the 'type' attribute for polymorphic beans and different ways to represent lists and maps. ```XML true 4 128 1 112233445566 1.3 1112232.43123 yf 1 C 1 2 1,2 1.2,2.3,3.4 1.2,2.2,3.2,4.3 1970-01-01 00:00:00 1 2 1 2 210 330 1 true 2 false 1 2 ``` -------------------------------- ### Set Custom Code Naming Convention Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line option to customize the naming style of generated code fields. Setting it to 'none' makes field names identical to their definitions. ```Shell --naming_convention_bean_member none ``` -------------------------------- ### XML Module Definition and Nesting Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/define Explains the `module` definition, including the `name` attribute for module naming, which can be empty or multi-level. It also covers nested sub-modules and how type namespaces are inherited within modules, showing how classes like Abc and Def get their full names. ```XML ``` -------------------------------- ### Generate Only Code for C# Unity JSON Project Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Command line option to generate only the code files for a C# Unity project using JSON data format, excluding data generation. ```Shell --gen_types code_cs_unity_json ``` -------------------------------- ### Define Resource-Tagged String Fields in Configuration Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/generatecodedata Illustrates how to tag a string field as a resource address in a bean definition using the '#res=xxx' attribute. This allows Luban to unify and export these resource paths. ```XML ``` -------------------------------- ### Luban Command-line Configuration for Text Type Validation Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/l10n Example command-line parameters to enable and configure text type validation in Luban. It sets the default text provider, specifies the path to the localization text file (JSON format requiring a '*@' prefix), and defines the field name for the localization key. These parameters are crucial for enabling text key validity checks. ```Shell -x l10n.provider=default ^ -x "l10n.textFile.path=*@D:\\workspace2\\luban_examples\\DataTables\\Datas\\l10n\\texts.json" ^ -x l10n.textFile.keyFieldName=key ``` -------------------------------- ### XML Data Format Example Source: https://luban.doc.code-philosophy.com/docs/help/faq/3.x/manual/otherdatasource Demonstrates a sample XML data structure with various element types, including boolean, integer, float, string, nested elements, and lists of items. It showcases how different data types are represented within the XML schema. ```XML true 4 128 1 112233445566 1.3 1112232.43123 yf 1 C 1 2 1 2 1 2 210 330 1 true 2 false 1 2 ``` -------------------------------- ### Example JSON Data Configuration for Luban Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/datasource This JSON snippet demonstrates various data types and structures supported by Luban, including boolean, integer, float, string, text objects, nested objects, arrays (set type), map-like arrays, and polymorphic bean types using the '$type' property. ```JSON { "x1":true, "x2":3, "x3":128, "x4":1, "x5":11223344, "x6":1.2, "x7":1.23432, "x10":"hq", "t1": {"key":"/key/xx1","text":"apple"}, "x12": { "x1":10}, "x13":"B", "x14":{"$type": "DemoD2", "x1":1, "x2":2}, "v2":{"x":1, "y":2}, "v3":{"x":1.1, "y":2.2, "z":3.4}, "v4":{"x":10.1, "y":11.2, "z":12.3, "w":13.4}, "t1":"1970-01-01 00:00:00", "k1":[1,2], "k2":[2,3], "k7":[2,3], "k8":[[2,2],[4,10]], "k9":[{"y1":1, "y2":true},{"y1":2, "y2":false}], "k15":[{"$type": "DemoD2", "x1":1, "x2":2}] } ``` -------------------------------- ### luban-client Command-Line General Parameters Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/commandtools This section details the general command-line parameters for `luban-client.dll`, including options for host, port, job type, log level, cache meta file, watch directories, and help. It provides an overview of the basic invocation syntax and available global flags. ```APIDOC dotnet Luban.Client.dll [-h ] [-p ] [-l ] [-c ] [-w ] [-h ] -j cfg -- 参数介绍: -h,--host 可选参数。 luban-server的地址。默认为 127.0.0.1 -p,--port 可选参数。 luban-server的端口。默认为 8899 -j,--job 必选参数。 生成类型。目前支持的生成类型有: cfg,proto,db。 生成配置请取cfg。 -l,--loglevel 可选参数。 日志级别。默认为INFO。有效值有: TRACE,DEBUG,INFO,WARN,ERROR,FATAL,OFF -c,--cachemetafile 可选参数。 meta缓存文件名。 默认为 .cache.meta -w,--watch 可选参数。 监测目录或者目录列表,以逗号';'分隔。当开启此选项后,生成结束后不会退出程序,而是进入自动生成模式。 监听到目标目录发生变化后,自动重新运行生成。省去改动后手动运行生成脚本的麻烦。 --generateonly 可选参数。 仅生成。不从服务器下载生成结果。可以用于检查服务器是否能成功生成。 -h,--help 可选参数。 显示帮助信息 -- 必选参数。 从此参数起,便是 不同job的特有选项 ``` -------------------------------- ### luban-client cfg Job-Specific Options Source: https://luban.doc.code-philosophy.com/docs/help/faq/1.x/manual/commandtools This section outlines the specific command-line options available when using the `cfg` job type with `luban-client.dll`. It covers parameters for defining files, input/output directories, generation types, validation, data output formats, template settings, naming conventions, localization, and language-specific configurations. ```APIDOC cfg的介绍: -d,--define_file 必选参数。 根定义文件名。 --input_data_dir 必选参数。 配置数据文件根目录。 --input:convert:dir 可选参数。 执行json、lua、xlsx之类数据格式转换时,提供的数据源,覆盖table中默认的input参数。 -c,--output_code_dir 可选参数。 生成代码文件的目录。 -s,--service 必选参数。生成分组目标。一般来说,会定义client,server,editor等好几个目标,不同目标的生成内容不同。 --gen_types 必选参数。生成任务类型。既可以是生成代码也可以是生成数据或者其他。 目前支持的有 code_cs_bin,code_cs_unity_bin,code_cs_dotnet_json,code_cs_unity_json, code_cs_unity_editor_json,code_lua_bin,code_java_bin,code_go_bin, code_go_json,code_cpp_bin,code_cpp_ue_editor_json,code_python27_json, code_python3_json, code_gdscript_json, code_typescript_bin,code_typescript_json,code_rust_json, code_protobuf2,code_protobuf3,code_template,code_flatbuffers, data_bin,data_bidx,data_lua,data_json,data_json_monolithic,data_bson,data_yaml, data_template,data_protobuf_bin,data_protobuf_json,data_flatbuffers_json, convert_json,convert_lua,convert_xlsx,convert_template --validate_root_dir . 可选参数。 配置path检查的根目录。 --output_data_dir 可选参数。 导出的数据文件的目录。只生成代码时可不指定。 --output:data:compact_json 可选参数。默认导出的json格式为对齐后的优雅格式,使用此参数后导出紧凑的不带空格和换行的格式。 --output:data:file_extension 可选参数。 导出数据文件的后缀。默认按照生成类型自动选择。 --output:exclude_tags 可选参数。导出时排除包含这些tag的数据 --output:tables 可选参数。手动指定导出哪些表。覆盖group中设置 --output:include_tables 可选参数。除了group中设置外,额外新增表。 --output:exclude_tables 可选参数。排除group中指定的表。 --output:convert:file_extension 可选参数。 convert数据文件的后缀。默认按照模板名猜测。 --template:code:dir 可选参数。自定义额外代码模板的目录名 --template:data:file