PageRenderTime 22ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Data/generator/do_items.lua

http://awoe.googlecode.com/
Lua | 96 lines | 70 code | 22 blank | 4 comment | 6 complexity | 09051435e529f70d1353437f8ebd33b6 MD5 | raw file
 1require 'os'
 2require 'engine'
 3
 4-- handle basic info sheet
 5local of_item = io.open("..\\items.lua", "w")
 6if not of_item then
 7	print("Failed to open output file: items.lua")
 8else
 9	of_item:write([[
10if not (type(items)=="table") then
11	items = {}
12end
13]])
14end
15
16-- handle equipment attr sheet
17local of_item_attr = io.open("..\\item_attr.lua", "w")
18if not of_item_attr then
19	print("Failed to open output file: item_attr.lua")
20else
21	of_item_attr:write([[
22if not (type(items)=="table") then
23	items = {}
24end
25]])
26end
27
28-- basic info sheet
29function handle_item(o)
30	local m = {} --item class
31	m.id 			= tonumber(o[1][1])
32	m.name 			= o[1][2]
33	m.level 		= tonumber(o[1][3])
34	m.icon 			= o[1][4]
35
36	m.quality		= tonumber(o[1][5])
37	m.type_des 		= o[1][6]
38	m.item_des  	= o[1][7]
39
40	m.suit_id		= tonumber(o[1][8])
41
42	m.buy_cost  	= tonumber(o[1][9])
43	m.sell_cost 	= tonumber(o[1][10])
44	m.yb_cost   	= tonumber(o[1][11])
45	m.ticket_cost 	= tonumber(o[1][12])
46
47	m.level_req 	= tonumber(o[1][13])
48
49	m.battle_use 	= tonumber(o[1][14])
50	m.death_use 	= tonumber(o[1][15])
51	m.can_discard 	= tonumber(o[1][16])
52	m.can_sale	 	= tonumber(o[1][17])
53	m.can_repair 	= tonumber(o[1][18])
54
55	m.bind_type 	= tonumber(o[1][19])
56
57	m.max_stack 	= tonumber(o[1][20])
58	m.success_rate 	= tonumber(o[1][21])
59	m.sing_time 	= tonumber(o[1][22])
60	m.cd_type	 	= tonumber(o[1][23])
61	m.hold_time 	= tonumber(o[1][24])
62	m.max_dur	 	= tonumber(o[1][25])
63
64	of_item:write("items[" .. m.id .. "] = ")
65	output_table(m, of_item)
66end
67
68-- attr sheet
69function handle_item_attr(o)
70	local attr = {} --attr class
71	attr.id = tonumber(o[1][1])
72
73	attr.basic = {} -- basic attr
74	for x = 2, 5 do
75		table.insert(attr.basic, tonumber(o[1][x]))
76	end
77
78	attr.growth = {} -- growth attr
79	for x = 6, 9 do
80		table.insert(attr.growth, tonumber(o[1][x]))
81	end
82
83	of_item_attr:write("items[" .. attr.id .. "] = ")
84	output_table(attr, of_item_attr)
85
86end
87
88
89export_csv("..\\..\\Document\\design\\????\\Item.xls", 5)
90
91
92
93handle_file("tmp\\Basic_Info.csv", 3, 1, handle_item)  -- basic info sheet
94handle_file("tmp\\Equipment_Attri.csv", 3, 1, handle_item_attr) -- attr sheet
95
96clear_csv()