当前位置:网站首页>Configuration file converted from Excel to Lua
Configuration file converted from Excel to Lua
2022-07-06 05:10:00 【Handsome_ shuai_】
Excel Convert to Lua Configuration file for
1. download Excel turn Lua Third party library
First, we download a third-party open source library , Here it is Excel Table to generate lua The configuration file , Download address https://github.com/XINCGer/Unity3DTraining/tree/master/XlsxTools
2. Prepare to build Lua The configuration file
- Follow Assets Under the same level directory , Create a new one Tools Folder , Then download the XlsxTools Put the folder here
- And then in debug Compile this solution in mode
There are several points to note in this document :
excel The file must be saved as .xls Format , instead of .xlsx Format
Lower left corner tab The tab name must be the same as the file name , And add a # Prefix , Like my one CharacterTable file ,tab The tab name is #CharacterTable
excel Before 4 Line has special meaning :
The first 1 The row is the name description of each field
The first 2 Row is the variable type of each field , Generally only support int and string type
The first 3 Row is the variable name of each field , This variable name can be used directly in code
The first 4 Line is comment , You can explain the meaning of this field in detail
And the most important point : The first field must be int type , And the variable name must be Id
- To configure .ini file , Set up Excel Read and output paths
- Next , We are Tools Create a new folder ExcelToLua.bat file , Used to automatically Excel The file generates the corresponding lua file
cd ./XlsxTools/Xls2Lua/Xls2Lua/bin/Debug/
Xls2Lua ^
pause
Double click Run to generate Lua The configuration file
3. Use Lua The configuration file
- establish ExcelMgr To manage all lua The configuration file
ExcelMgr = {
}
-- Excel Table manager
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
边栏推荐
- Bill Gates posted his 18-year-old resume and expected an annual salary of $12000 48 years ago
- Acwing week 58
- Postman关联
- MySQL time processing
- C# AES对字符串进行加密
- ORM aggregate query and native database operation
- RTP gb28181 document testing tool
- GAMES202-WebGL中shader的编译和连接(了解向)
- Request (request object) and response (response object)
- SQL injection vulnerability (MSSQL injection)
猜你喜欢
Excel转换为Lua的配置文件
Zynq learning notes (3) - partial reconfiguration
Hyperledger Fabric2. Some basic concepts of X (1)
Imperial cms7.5 imitation "D9 download station" software application download website source code
Idea one key guide package
【LeetCode】18、四数之和
Summary of redis basic knowledge points
[mathematical modeling] differential equation -- sustainable development of fishing industry
Lepton 无损压缩原理及性能分析
Acwing week 58
随机推荐
Simple understanding of interpreters and compilers
Acwing week 58
C# AES对字符串进行加密
MySQL time processing
Postman manage test cases
2021 robocom world robot developer competition - undergraduate group (semi-finals)
Hyperledger Fabric2. Some basic concepts of X (1)
Compilation and connection of shader in games202 webgl (learn from)
[数学建模] 微分方程--捕鱼业的持续发展
Application of Flody
RTP gb28181 document testing tool
[effective Objective-C] - memory management
Yyds dry inventory SSH Remote Connection introduction
Sliding window problem review
浅谈镜头滤镜的类型及作用
Modbus协议通信异常
CUDA11.1在线安装
The kernel determines whether peripherals are attached to the I2C address
Leetcode dynamic planning day 16
[mathematical modeling] differential equation -- sustainable development of fishing industry