Convert csv to lua script for game res
building.csv
name | use_money | use_food | is_init | defense |
string | number | number | bool | number |
名字 | 使用金币数 | 使用食物数 | 是否初始化 | 防御力 |
house | 1000 | 123 | TRUE | 100 |
123 | 120 | |||
456 | 130 | |||
farm | 100 | 234 | FALSE | 200 |
200 | ||||
200 |
The first row must be title.
The second row must be type(number, string, bool) The third row must be interpretation.
The first column must be Name.
-- this file is generated by program!
-- don't change it manaully.
-- source file: building.csv
-- created at: Wed Sep 3 15:55:49 2014
local building = {}
building.house = {
use_money = 1000,
use_food = 123,
is_init = true,
}
building.house[1] = {
use_money = 1000,
use_food = 123,
is_init = true,
}
building.house[2] = {
use_money = 123,
}
building.house[3] = {
use_money = 456,
}
building.farm = {
use_money = 100,
use_food = 234,
is_init = false,
}
building.farm[1] = {
use_money = 100,
use_food = 234,
is_init = false,
}
building.farm[2] = {
use_money = 200,
}
building.farm[3] = {
use_money = 200,
}
building.all_type = {}
local all_type = building.all_type
all_type[1] = house
all_type[2] = farm
for i=1, #(building.all_type) do
local item = building.all_type[i]
for j=1, #item do
item[j].__index = item[j]
if j < #item then
setmetatable(item[j+1], item[j])
end
end
end
return building
local building = require("building")
print(building.farm[1].use_money)
print(building.farm.use_money)
The console will print
100
100