xls2lua
---------------------------
Convert xls to lua script for game resource
(将xls数据文件转化为lua脚本,作为游戏资源使用)
use [python xlrd](https://pypi.python.org/pypi/xlrd)
(使用python xlrd模块)
Blog: http://www.luzexi.com
Email: [email protected]
# What's this.(是什么)
This is a script to convert xls to lua.
If you use lua language , the data write in lua is the best thing for you to code.
So this script will help you convert xls to lua , so you can do your job more easily.
(如果你在使用Lua语言,将数据写进Lua文件是最方便的做法。这个脚本将帮助你将数据xls文件转化为lua文件,这样你就可以更好的工作了。)
### Declare (声明)
This script is inherit from https://github.com/zfengzhen/xls2lua .
I improve it to fit my data rule like add array type in script and remove the different talbe name in xls and so on.
Any way , you can choose one that more fit your project.
(这个脚本是从 https://github.com/zfengzhen/xls2lua 继承过来的,我改进了很多东西,也去除了很多东西,我改成了适合我自己的脚本。不管怎样,你可以选择一个适合你的脚本去运行。)
### Example(例子xls表格)
example_building.xls
<table>
<tr>
<td>id</td>
<td>name</td>
<td>use_money</td>
<td>use_food</td>
<td>is_init</td>
<td>defense</td>
<td>args1</td>
<td>args2</td>
<td>args3</td>
<td>args4</td>
</tr>
<tr>
<td>i</td>
<td>s</td>
<td>i</td>
<td>f</td>
<td>b</td>
<td>i</td>
<td>ai</td>
<td>af</td>
<td>as</td>
<td>ab</td>
</tr>
<tr>
<td>1</td>
<td>house</td>
<td>1000</td>
<td>2.33</td>
<td>TRUE</td>
<td>100</td>
<td>1;2;3</td>
<td>1.23;2;3.23</td>
<td>sdf;23e;s</td>
<td>true;false;true</td>
</tr>
<tr>
<td>2</td>
<td>house2</td>
<td>123</td>
<td>336.2</td>
<td>TRUE</td>
<td></td>
<td>1;2;3</td>
<td>1;2.3445;3</td>
<td>你好;你在哪</td>
<td>true;false</td>
</tr>
<tr>
<td>3</td>
<td></td>
<td>456</td>
<td>222.33665</td>
<td>FALSE</td>
<td>130</td>
<td>3;2;5;;</td>
<td>3;2;2.5;;</td>
<td>我在这里啊;你在那;呢</td>
<td>false;true</td>
</tr>
<tr>
<td>4</td>
<td>farm</td>
<td>100</td>
<td>220</td>
<td>FALSE</td>
<td>200</td>
<td>2;3;</td>
<td>200.3;3;234.23;</td>
<td>df;ssd;dd;dd</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>house5</td>
<td></td>
<td>22.1</td>
<td></td>
<td>2343;6;6;;;7</td>
<td>3;6.3;6;;;7</td>
<td>ss;d;d;d</td>
<td>true;true</td>
</tr>
<tr>
<td>6</td>
<td>horse3</td>
<td>200</td>
<td></td>
<td>FALSE</td>
<td>333</td>
<td></td>
<td></td>
<td>2e;w;e;we</td>
<td>false;false;false;false</td>
</tr>
</table>
### Excute Example (举例执行命令)
python ./xls2lua.py example_building.xls ./data/
### NOTICE:(注意点)
> The sheet name must start with "output_" , the lua file name will be the name behind "output_". <br />
> The **first row** must be **title**. <br />
> The **second row** must be **type** <br />
> The **type must be i , f , s , b , ai , af , as , ab. <br />
> i mean int , f mean float , s mean string , b mean bool , ai mean array int , af mean array float , as mean array string , ab mean array bool. <br />
> The **first column** must be int , so the type in first column must be i. <br />
> The string type with char **"** or **'** will be replace by \" or \' <br />
> The empty col will be a default value like 0 or "" or false or {} <br />
> (sheet名以"output_"开头的才会被识别转换,否则将被忽略) <br />
> (第1行必须是关键字名) <br />
> (第2行必须为类型) <br />
> (类型有:i,f,s,b,ai,af,as,ab这几种) <br />
> (i表示int,f表示float,s表示string,b表示bool,ai表示int数组,af表示float数组,as表示string数组,ab表示bool数组) <br />
> (第1列必须为int类型的唯一关键字) <br />
> (string类型中"和'会自动用\"和\'替代)
> (空列将会被默认值代替,例如:0,"",false,{})
### Lua script (生成后的Lua文件示例)
```lua
-- this file is generated by program!
-- don't change it manaully.
-- source file: example_building.xls
-- created at: Thu Mar 26 02:53:52 2015
local data = {}
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}}
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}}
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}}
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 = {}}
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}}
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}}
return data
```
### How to use lua with data. (如何使用生成的lua数据)
```lua
local building = require "building"
print(building[1].name)
```
The console will print "house"
没有合适的资源?快使用搜索试试~ 我知道了~
c#游戏开发基于unity3d的回合制RPG游戏源码.zip

共2000个文件
meta:1069个
cs:228个
lua:169个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 126 浏览量
2024-05-06
09:42:24
上传
评论
收藏 27.47MB ZIP 举报
温馨提示
c#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zipc#游戏开发基于unity3d的回合制RPG游戏源码.zip
资源推荐
资源详情
资源评论























格式:rar 资源大小:11.7MB





收起资源包目录





































































































共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论


海神之光.
- 粉丝: 6119
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
