|
1 |
| -xls2lua 基于Python3.X使用 (将xls数据文件转化为lua脚本,作为游戏资源使用) |
| 1 | +xls2lua 基于Python3.X使用 |
| 2 | +(将xls数据文件转化为lua脚本,作为游戏资源使用) |
2 | 3 |
|
3 |
| -use python xlrd |
| 4 | +use [python xlrd](https://pypi.python.org/pypi/xlrd) |
4 | 5 |
|
5 | 6 | (使用python xlrd模块)
|
6 | 7 |
|
7 |
| -(这个脚本是从 https://github.com/zfengzhen/xls2lua 和 https://github.com/luzexi/xls2lua 继承过来的,我改进了很多东西,使得更适合游戏项目使用。) |
| 8 | +(这个脚本是从 https://github.com/zfengzhen/xls2lua,https://github.com/luzexi/xls2lua 继承过来的,我改进了很多东西,使得更适合游戏项目使用。) |
8 | 9 |
|
9 | 10 | (如果你在使用Lua语言,将数据写进Lua文件是最方便的做法。这个脚本将帮助你将数据xls文件转化为lua文件,这样你就可以更好的工作了。)
|
10 | 11 |
|
11 |
| -(举例执行命令,其中有.bat批处理,下载之后可以直接使用) |
12 |
| - |
13 |
| -python ./xls2lua.py |
14 |
| - |
15 |
| -NOTICE:(注意点) |
16 |
| - |
17 |
| -(sheet名以"OUT_"开头的才会被识别转换,否则将被忽略) |
18 |
| -(第1行无用,是关键字名的介绍描述) |
19 |
| -(第2行必须是关键字名) |
20 |
| -(第3行必须为类型) |
21 |
| -(类型有:int,float,string,boolean,intArr,floatArr,stringArr,booleanArr这几种) |
22 |
| -(intArr表示int数组,floatArr表示float数组,stringArr表示string数组,booleanArr表示bool数组) |
23 |
| -(第1列必须为int类型的唯一关键字) |
24 |
| -(string类型中"和'会自动用\"和\'替代) (空列将会被默认值代替,例如:0,"",false,{}) |
25 |
| -Lua script (生成后的Lua文件示例) |
26 |
| - |
27 |
| --- This file is generated by program! |
28 |
| --- Don't change it manaully. |
29 |
| --- Author: [email protected] NormanYang |
30 |
| --- Source file: 策划数值配置/英雄表.xlsx |
31 |
| --- Created at: Thu Dec 17 08:57:14 2015 |
32 |
| - |
| 12 | +### Excute Example (举例执行命令) |
| 13 | +python ./xls2lua.py Building.xlsx ./Config/ |
| 14 | + |
| 15 | +### NOTICE:(注意点) |
| 16 | +> (sheet名以"OUT_"开头的才会被识别转换,否则将被忽略) <br /> |
| 17 | +> (第1行无用,是关键字名的介绍描述) <br /> |
| 18 | +> (第2行必须是关键字名) <br /> |
| 19 | +> (第3行必须为类型) <br /> |
| 20 | +> (类型有:int,float,string,boolean,intArr,floatArr,stringArr,booleanArr这几种) <br /> |
| 21 | +> (intArr表示int数组,floatArr表示float数组,stringArr表示string数组,booleanArr表示bool数组) <br /> |
| 22 | +> (第1列必须为int类型的唯一关键字) <br /> |
| 23 | +> (string类型中"和'会自动用\"和\'替代) |
| 24 | +> (空列将会被默认值代替,例如:0,"",false,{}) |
| 25 | +
|
| 26 | +### Lua script (生成后的Lua文件示例) |
| 27 | +```lua |
| 28 | +-- this file is generated by program! |
| 29 | +-- don't change it manaully. |
| 30 | +-- source file: example_building.xls |
| 31 | +-- created at: Thu Mar 26 02:53:52 2015 |
33 | 32 |
|
34 | 33 | local data = {}
|
35 | 34 |
|
36 |
| -data[1000] = { id = 1000, name = "house", use_money = 1000, use_food = 2.33, is_init = true, defense = 100, args1 = {1,2,3}, args2 = {1.23,2,3.23}, args3 = {"sdf","23e","s"}, args4 = {true,false,true}} |
37 |
| -data[1001] = { id = 1001, name = "你好吗?", use_money = 123, use_food = 336.2, is_init = true, defense = 0, args1 = {1,2,3}, args2 = {1,2.3445,3}, args3 = {"你好","你在哪"}, args4 = {true,false}} |
38 |
| -data[1002] = { id = 1002, name = "", use_money = 456, use_food = 222.33665, is_init = false, defense = 130, args1 = {3,2,5}, args2 = {3,2,2.5}, args3 = {"我在这里啊","你在那","呢"}, args4 = {false,true}} |
39 |
| -data[1003] = { id = 1003, name = "farm", use_money = 100, use_food = 220.0, is_init = false, defense = 200, args1 = {2,3}, args2 = {200.3,3,234.23}, args3 = {"df","ssd","dd","dd"}, args4 = {}} |
40 |
| -data[1004] = { id = 1004, name = "house5", use_money = 0, use_food = 22.1, is_init = false, defense = 234, args1 = {3,6,6,7}, args2 = {3,6.3,6,7}, args3 = {"ss","d","d","d"}, args4 = {true,true}} |
41 |
| -data[1005] = { id = 1005, name = "horse3", use_money = 200, use_food = 0, is_init = false, defense = 333, args1 = {}, args2 = {}, args3 = {"2e","w","e","we"}, args4 = {false,false,false,false}} |
| 35 | +data[1] = { id = 1, name = "house", use_money = 1000, use_food = 2.33, is_init = true, defense = 100, aadd = {1,2,3}, aadddss = {1.23,2,3.23}, ddff = {"sdf","23e","s"}, ffdd = {true,false,true}} |
| 36 | +data[2] = { id = 2, name = "house2", use_money = 123, use_food = 336.2, is_init = true, defense = 0, aadd = {1,2,3}, aadddss = {1,2.3445,3}, ddff = {"你好","你在哪"}, ffdd = {true,false}} |
| 37 | +data[3] = { id = 3, name = "", use_money = 456, use_food = 222.33665, is_init = false, defense = 130, aadd = {3,2,5}, aadddss = {3,2,2.5}, ddff = {"我在这里啊","你在那","呢"}, ffdd = {false,true}} |
| 38 | +data[4] = { id = 4, name = "farm", use_money = 100, use_food = 220.0, is_init = false, defense = 200, aadd = {2,3}, aadddss = {200.3,3,234.23}, ddff = {"df","ssd","dd","dd"}, ffdd = {}} |
| 39 | +data[5] = { id = 5, name = "house5", use_money = 0, use_food = 22.1, is_init = false, defense = 234, aadd = {3,6,6,7}, aadddss = {3,6.3,6,7}, ddff = {"ss","d","d","d"}, ffdd = {true,true}} |
| 40 | +data[6] = { id = 6, name = "horse3", use_money = 200, use_food = 0, is_init = false, defense = 333, aadd = {}, aadddss = {}, ddff = {"2e","w","e","we"}, ffdd = {false,false,false,false}} |
42 | 41 |
|
43 | 42 | return data
|
44 |
| -How to use lua with data. (如何使用生成的lua数据) |
45 | 43 |
|
| 44 | +``` |
| 45 | + |
| 46 | +### How to use lua with data. (如何使用生成的lua数据) |
| 47 | +```lua |
46 | 48 | local building = require "Building"
|
47 | 49 |
|
48 | 50 | print(building[1].name)
|
49 |
| -The console will print "house" |
| 51 | +``` |
| 52 | +The console will print "house" |
0 commit comments