/Data/generator/do_items.lua

http://awoe.googlecode.com/ · Lua · 96 lines · 94 code · 1 blank · 1 comment · 3 complexity · 09051435e529f70d1353437f8ebd33b6 MD5 · raw file

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