当前位置:网站首页>Excel转换为Lua的配置文件
Excel转换为Lua的配置文件
2022-07-06 05:02:00 【帅_shuai_】
Excel转换为Lua的配置文件
1.下载Excel转Lua的第三方库
首先我们下载一个第三方开源库,来给Excel表生成lua配置文件,下载地址https://github.com/XINCGer/Unity3DTraining/tree/master/XlsxTools
2.准备生成Lua配置文件
- 在跟Assets平级的目录下,新建一个Tools文件夹,然后把下载的XlsxTools文件夹放在这里
- 然后在debug模式下编译这个解决方案
这个文件有几点需要注意:
excel文件必须保存为.xls格式,而不是.xlsx格式
左下角的tab页签名字必须个文件名一样,并且加一个#前缀,比如我的这个CharacterTable文件,tab页签名字是#CharacterTable
excel的前4行是有特殊含义的:
第1行是每个字段的名字说明
第2行是每个字段的变量类型,一般只支持int和string类型
第3行是每个字段的变量名字,这个变量名字是可以在代码中直接使用的
第4行是注释,可以详细解释这个字段的含义
还有最重要的一点:首字段必须是int型,并且变量名必须是Id
- 配置.ini文件,设置Excel读取和输出的路径
- 接下来,我们在Tools文件夹下新建一个ExcelToLua.bat文件,用来自动将Excel文件生成出对应的lua文件
cd ./XlsxTools/Xls2Lua/Xls2Lua/bin/Debug/
Xls2Lua ^
pause
双击运行即可生成Lua配置文件
3.使用Lua配置文件
- 创建ExcelMgr 来管理所有的lua配置文件
ExcelMgr = {
}
-- Excel表管理器
ExcelMgr.CacheTable = {
}
ExcelMgr.CacheTableRow = {
}
function ExcelMgr:GetTable(tableName)
local oneTable = self.CacheTable[tableName]
if oneTable ~= nil then
return oneTable
end
oneTable = require(tableName)
self.CacheTable[tableName] = oneTable
return self.CacheTable[tableName]
end
function ExcelMgr:GetRow(tableName, id)
if self.CacheTableRow[tableName] == nil then
local oneTable = self:GetTable(tableName)
self.CacheTableRow[tableName] = {
}
for _,v in ipairs(oneTable) do
self.CacheTableRow[tableName][v.Id]= v
end
end
if self.CacheTableRow[tableName] then
return self.CacheTableRow[tableName][id]
end
end
return ExcelMgr
边栏推荐
- Flink kakfa data read and write to Hudi
- 几种RS485隔离通讯的方案介绍
- MPLS experiment
- Orm-f & Q object
- 关于Unity Inspector上的一些常用技巧,一般用于编辑器扩展或者其他
- Idea one key guide package
- Sorting out the knowledge points of multicast and broadcasting
- Imperial cms7.5 imitation "D9 download station" software application download website source code
- Fiddler installed the certificate, or prompted that the certificate is invalid
- The kernel determines whether peripherals are attached to the I2C address
猜你喜欢
RT thread analysis log system RT_ Kprintf analysis
Ora-01779: the column corresponding to the non key value saving table cannot be modified
Embedded development program framework
ISP学习(2)
程序员在互联网行业的地位 | 每日趣闻
Fuzzy -- basic application method of AFL
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Review of double pointer problems
Postman pre script - global variables and environment variables
Pagoda configuration mongodb
随机推荐
Postman断言
Upload nestjs configuration files, configure the use of middleware and pipelines
Ad20 is set with through-hole direct connection copper sheet, and the bonding pad is cross connected
内核判断i2c地址上是否挂载外设
2021 robocom world robot developer competition - undergraduate group (semi-finals)
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
比尔·盖茨晒18岁个人简历,48年前期望年薪1.2万美元
The kernel determines whether peripherals are attached to the I2C address
Leetcode 186 Flip the word II in the string (2022.07.05)
Supreme Court, judgment standard of divorce cases
Collection + interview questions
RTP gb28181 document testing tool
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[buuctf.reverse] 159_[watevrCTF 2019]Watshell
Introduction of several RS485 isolated communication schemes
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[NOIP2008 提高组] 笨小猴
On the solution of es8316's audio burst
Basic knowledge and examples of binary tree
[leetcode16] the sum of the nearest three numbers (double pointer)