/Data/generator/do_items.lua
http://awoe.googlecode.com/ · Lua · 96 lines · 94 code · 1 blank · 1 comment · 3 complexity · 09051435e529f70d1353437f8ebd33b6 MD5 · raw file
- require 'os'
- require 'engine'
-
- -- handle basic info sheet
- local of_item = io.open("..\\items.lua", "w")
- if not of_item then
- print("Failed to open output file: items.lua")
- else
- of_item:write([[
- if not (type(items)=="table") then
- items = {}
- end
- ]])
- end
-
- -- handle equipment attr sheet
- local of_item_attr = io.open("..\\item_attr.lua", "w")
- if not of_item_attr then
- print("Failed to open output file: item_attr.lua")
- else
- of_item_attr:write([[
- if not (type(items)=="table") then
- items = {}
- end
- ]])
- end
-
- -- basic info sheet
- function handle_item(o)
- local m = {} --item class
- m.id = tonumber(o[1][1])
- m.name = o[1][2]
- m.level = tonumber(o[1][3])
- m.icon = o[1][4]
-
- m.quality = tonumber(o[1][5])
- m.type_des = o[1][6]
- m.item_des = o[1][7]
-
- m.suit_id = tonumber(o[1][8])
-
- m.buy_cost = tonumber(o[1][9])
- m.sell_cost = tonumber(o[1][10])
- m.yb_cost = tonumber(o[1][11])
- m.ticket_cost = tonumber(o[1][12])
-
- m.level_req = tonumber(o[1][13])
-
- m.battle_use = tonumber(o[1][14])
- m.death_use = tonumber(o[1][15])
- m.can_discard = tonumber(o[1][16])
- m.can_sale = tonumber(o[1][17])
- m.can_repair = tonumber(o[1][18])
-
- m.bind_type = tonumber(o[1][19])
-
- m.max_stack = tonumber(o[1][20])
- m.success_rate = tonumber(o[1][21])
- m.sing_time = tonumber(o[1][22])
- m.cd_type = tonumber(o[1][23])
- m.hold_time = tonumber(o[1][24])
- m.max_dur = tonumber(o[1][25])
-
- of_item:write("items[" .. m.id .. "] = ")
- output_table(m, of_item)
- end
-
- -- attr sheet
- function handle_item_attr(o)
- local attr = {} --attr class
- attr.id = tonumber(o[1][1])
-
- attr.basic = {} -- basic attr
- for x = 2, 5 do
- table.insert(attr.basic, tonumber(o[1][x]))
- end
-
- attr.growth = {} -- growth attr
- for x = 6, 9 do
- table.insert(attr.growth, tonumber(o[1][x]))
- end
-
- of_item_attr:write("items[" .. attr.id .. "] = ")
- output_table(attr, of_item_attr)
-
- end
-
-
- export_csv("..\\..\\Document\\design\\????\\Item.xls", 5)
-
-
-
- handle_file("tmp\\Basic_Info.csv", 3, 1, handle_item) -- basic info sheet
- handle_file("tmp\\Equipment_Attri.csv", 3, 1, handle_item_attr) -- attr sheet
-
- clear_csv()