Giter VIP home page Giter VIP logo

csvtolua's Introduction

csvtolua

Convert csv to lua script for game res

example

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
lua csvtolua.lua building.csv

NOTICE:

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.

LUA SCRIPT

-- 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

HOW TO USE LUA SCRIPT

local building = require("building")

print(building.farm[1].use_money)
print(building.farm.use_money)

The console will print
100
100

csvtolua's People

Contributors

zfengzhen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.