# Luban [![license](http://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Build Status](https://travis-ci.com/focus-creative-games/luban.svg?branch=main)](https://travis-ci.com/focus-creative-games/luban ) ![Docker Auto](https://img.shields.io/docker/cloud/automated/hugebug4ever/luban.svg) ![Docker Build](https://img.shields.io/docker/cloud/build/hugebug4ever/luban.svg) ![icon](docs/images/icon.png) ----- ## links - [README - English](./README.en-us.md) - [github link](https://github.com/focus-creative-games/luban) - [gitee link](https://gitee.com/focus-creative-games/luban) ----- ## introduce luban is your **best game configuration solution**. Luban efficiently processes data such as excel, json, and xml common in game development, checks data errors, generates codes in various languages such as c#, and exports them into various formats such as bytes or json. luban unifies the game configuration development workflow, greatly improving the efficiency of planning and programming. ## Core features - Powerful data analysis and conversion capabilities {excel(csv,xls,xlsx), json, bson, xml, yaml, lua, unity ScriptableObject} => {binary, json, bson, xml, lua, yaml, erlang, custom format } - Enhanced excel format, which can succinctly configure simple lists, substructures, structured lists, and arbitrarily complex deep nested structures. - Complete type system, **Support OOP type inheritance**, with data in excel, json, lua, xml and other formats **Flexible and elegant** Express complex GamePlay data such as behavior trees, skills, plots, and copies - Supports generating c#, java, go, c++, lua, python, javascript, typescript, erlang, rust, gdscript code - Support generating protobuf(schema + binary + json), flatbuffers(schema + json), msgpack(binary) - Powerful data verification capability. ref reference check, path resource path, range range check, etc. - Perfect localization support. Static text value localization, dynamic text value localization, time localization, main-patch multi-region version - Powerful and flexible customization capabilities, support for custom code templates and data templates - **Universal generation and caching tool**. It can also be used to generate code such as protocols, databases, and even as an object caching service - **Good support for mainstream engines, all platforms, mainstream hot update solutions, and mainstream front-end and back-end frameworks**. Supports mainstream engines such as Unity, Unreal, Cocos2x, Godot, and WeChat games. The tool itself is cross-platform and can work well on Win, Linux, and Mac platforms. See [feature](https://focus-creative-games.github.io/luban-doc/#/manual/traits) for complete features ## Documentation - [Official Documentation](https://focus-creative-games.github.io/luban-doc/) - [Quickstart](https://focus-creative-games.github.io/luban-doc/#/beginner/quickstart) - **Example Project** ([github](https://github.com/focus-creative-games/luban_examples)) ([gitee](https://gitee.com/focus-creative-games/luban_examples) ) - [Version Change Log](https://focus-creative-games.github.io/luban-doc/#/changelog) - Support and contact - QQ group: 692890842 (Luban development exchange group). If you have any questions about usage, please join the QQ group to ask in time, and someone will help you solve it at any time. - Email: luban@code-philosophy.com ## Excel format overview For a complete example, please refer to [Excel Format Introduction](https://focus-creative-games.github.io/lubandoc/excel.html) ### Normal table |##var| id | x1 | x5 | x6 | s1 | s2 | v3 | t1 | | -|- | -| -| -| -| - | - | - | |##type|int|bool|long|float|string|text#sep=\||vector3|datetime| |##|id|desc1|desc2|desc3|desc4|desc7|desc1|time| || 1|false| 1000| 1.2| hello |key1\|world1|1,2,3|1999-10-10 11:12:13| || 2|true| 1000| 2.4|world |key2\|world2|2,4,5|1999-10-12 11:12:13| ### Raw data list
##var id arr1 arr2 arr3 arr4
##type int (array#sep=;),int list,int (list#sep=|),string list,string
## id desc1 desc2 desc3 desc4
1 1;2;3 12 xx|yy xxxzzz
2 2;4 345 aaaa|bbbb|cccc aaabbbccc
3 2;4;6 3456 aaaa|bbbb|cccc aaabbbccc
### substructure Reward is a substructure containing the three fields of "int item_id; int count; string desc;".
##varidrewardreward2reward3
##typeintRewardRewardReward#sep=,
##varitem_idcountdesc
1100110item 11002< /td>11item 21002,1,item 3
2200110item 22002< /td>20item 42003,2,item 5
### Structure List 1
##var id rewards1 rewards2
##type int list,Reward list,Reward#sep=,
## id reward list desc1 reward list desc2
1 10011desc110022desc2 1001,1,desc11002,2,desc21003,3,desc3
2 10011desc1 1001,1,desc11002,2,desc2
### Structure List 2
##var id name rewards
##type int string list,Reward
##var 0 1 2
1task1100110desc1100212desc2100313desc3
2task1100330desc3100440desc4
3task1100550desc5
### Structure List 3
##var id name rewards
##type int string list,Reward
##var 0 1 2
##var item_idnumdesc item_idnumdesc item_idnumdesc
1task1100110desc1100212desc2100313desc3
2task1100330desc3100440desc4
3task1100550desc5
### Multi-row table
##var id name *stages
##type int string list,Stage
##var id name desc location item_id num
## id desc1 desc1 desc2 desc3 desc4 desc5 desc6
1 task1 1stage1stage desc11,2,310011
2stage2stage desc21,2,310011
3stage3stage desc31,2,310021
2 task2 1stage1stage desc11,2,310011
2stage2stage desc21,2,310021
### Multi-level subheadings of type map
##varidlans
##typeintmap,string,string
##varch-znenjpfr
1appleappleaaaaaa
2bananabananabbbbbb
### Type inheritance (suitable for skills, buff related configuration)
##varidshapeshape2
##typeintShapeShape
##var$typeradiuswidthheight
1Circle10Circle100
2Rectangle1020Rectangle1020
3Circle10Triangle151515
4Circle10Rectangle3020
### Multiple primary key table (joint index) Multiple keys form a joint unique primary key. |##var|key1|key2|key3| num| |-|-|-|-|-| |##type|int|long|string|int| ||1|1|aaa|123| ||1|1|bbb|124| ||1|2|aaa|134| ||2|1|aaa|124| ||5|6|xxx|898| ### Multiple primary key table (independent index) Multiple keys are indexed independently. |##var|key1|key2|key3| num| |-|-|-|-|-| |##type|int|long|string|int| ||1|2|aaa|123| ||2|4|bbb|124| ||3|6|ccc|134| ||4|8|ddd|124| ||5|10|eee|898| ### Singleton table Some configurations only have one copy globally, such as the opening level of the guild module, the initial size of the backpack, and the upper limit of the backpack. In this case, it is more appropriate to use a singleton table to configure these data. |##var| guild_open_level | bag_init_capacity | bag_max_capacity | newbie_tasks | | - |- | - | - | - | | ##type | int | int | int | list,int| | ## |desc1 |desc2 |desc3 |desc4| | | 10 | 100 | 500 | 10001, 10002 | ### Vertical table
##var#column ##type ##
guild_open_levelintdesc110
bag_init_capacityintdesc2100
bag_max_capacityintdesc3500
newbie_taskslist,intdesc410001,10002
## json, lua, xml, yaml format quick overview Take the behavior tree as an example to show how to configure the behavior tree configuration in json format. For formats such as xml, lua, yaml, etc., please refer to [detailed documentation](https://focus-creative-games.github.io/luban/data_source/). ````json { "id": 10002, "name": "random move", "desc": "demo behaviour tree", "executor": "SERVER", "blackboard_id": "demo", "root": { "$type": "Sequence", "id": 1, "node_name": "test", "desc": "root", "services": [], "decorators": [ { "$type": "UeLoop", "id": 3, "node_name": "", "flow_abort_mode": "SELF", "num_loops": 0, "infinite_loop": true, "infinite_loop_timeout_time": -1 } ], "children": [ { "$type": "UeWait", "id": 30, "node_name": "", "ignore_restart_self": false, "wait_time": 1, "random_deviation": 0.5, "services": [], "decorators": [] }, { "$type": "MoveToRandomLocation", "id": 75, "node_name": "", "ignore_restart_self": false, "origin_position_key": "x5", "radius": 30, "services": [], "decorators": [] } ] } } ```` ## Code usage preview Here we only briefly show the usage of c#, typescript, and go languages ​​in development. For more languages ​​and more detailed usage examples and codes, see [Example Project](https://github.com/focus-creative-games/luban_examples). - C# usage example ````C# // One line of code can load all configuration. cfg.Tables contains one instance field for all tables. var tables = new cfg.Tables(file => return new ByteBuf(File.ReadAllBytes(gameConfDir + "/" + file + ".bytes"))); // access a singleton table Console.WriteLine(tables.TbGlobal.Name); // access the normal key-value table Console.WriteLine(tables.TbItem.Get(12).Name); // support operator [] usage Console.WriteLine(tables.TbMail[1001].Desc); ```` - Typescript usage example ```typescript // One line of code can load all configuration. cfg.Tables contains one instance field for all tables. let tables = new cfg.Tables(f => JsHelpers.LoadFromFile(gameConfDir, f)) // access a singleton table console.log(tables.TbGlobal.name) // access the normal key-value table console.log(tables.TbItem.get(12).Name) ```` - go example ````go // One line of code can load all configuration. cfg.Tables contains one instance field for all tables. if tables , err := cfg.NewTables(loader) ; err != nil { println(err.Error()) return } // access a singleton table println(tables.TbGlobal.Name) // access the normal key-value table println(tables.TbItem.Get(12).Name) ```` ## route map - [ ] Added unity built-in editor - [ ] Added unreal built-in editor - [ ] Supplemental unit tests ## License Luban is licensed under the [MIT](LICENSE.TXT) license.