read_armor_config.lua 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. local S=minerdream.intllib
  2. local has_value = basic_functions.has_value
  3. local tier_cols={
  4. col_num={"name"},}
  5. local tier_definition = basic_functions.import_csv(minerdream.path.."/tiers.txt",tier_cols)
  6. local tool_cols={
  7. col_num={"range","uses"},
  8. as_numeric=1,
  9. }
  10. local tool_definition = basic_functions.import_csv(minerdream.path.."/armor.txt",tool_cols)
  11. for i,tdef in pairs(tool_definition) do
  12. if (i ~= "default") then
  13. local tooldef={}
  14. for col in pairs(tdef) do
  15. tooldef=basic_functions.parse_tree(tooldef,col,tdef[col])
  16. end
  17. if minerdream.itemdef[i]==nil then
  18. minerdream.itemdef[i]={}
  19. end
  20. local tierd=tier_definition[tostring(tdef.tier)]
  21. for _,tool in pairs({"helmet","chestplate","boots","leggings","shields"}) do
  22. if tooldef[tool] ~= nil then
  23. minerdream.itemdef[i][tool]=tooldef[tool]
  24. local ttv=tooldef[tool]
  25. tdesc=core.colorize("#"..tierd.color, S(i:gsub("^%l", string.upper)).." "..S(tool:gsub("^%l", string.upper)).."\n")..
  26. core.colorize("#A0A0A0", "tier: "..tierd.name.." ("..tierd.desc..")")
  27. if ttv.fleshy then
  28. tdesc=tdesc.."\n"..core.colorize("#A0A0A0",S("Defense")..": "..ttv.fleshy)
  29. end
  30. if ttv.heal then
  31. tdesc=tdesc.."\n"..core.colorize("#A0A0A0",S("Heal")..": "..ttv.heal)
  32. end
  33. if ttv.speed then
  34. tdesc=tdesc.."\n"..core.colorize("#A0A0A0",S("Walking speed")..": "..(ttv.speed*100).."%")
  35. end
  36. if ttv.gravity then
  37. tdesc=tdesc.."\n"..core.colorize("#A0A0A0",S("Gravity")..": "..(ttv.gravity*100).."%")
  38. end
  39. if ttv.jump then
  40. tdesc=tdesc.."\n"..core.colorize("#A0A0A0",S("Jump force")..": "..(ttv.jump*100).."%")
  41. end
  42. tt_def={description=tdesc,
  43. -- tt_def={description=i.." "..tool,
  44. inventory_image=minerdream.modname.."_inv_"..tool.."_"..i..".png",
  45. damage_groups = {level = ttv.level or 2},
  46. armor_groups={fleshy=ttv.fleshy or 10},
  47. groups={armor_heal=ttv.heal,armor_use=ttv.use,
  48. physics_jump=ttv.jump,physics_speed=ttv.speed,physics_gravity=ttv.gravity}
  49. }
  50. for _,gc in pairs({"cracky","crumbly","choppy","snappy"}) do
  51. tt_def.damage_groups[gc]=ttv[gc]
  52. end
  53. if tool == "helmet" then
  54. tt_def.groups.armor_head=1
  55. elseif tool == "chestplate" then
  56. tt_def.groups.armor_torso=1
  57. elseif tool == "leggings" then
  58. tt_def.groups.armor_legs=1
  59. elseif tool == "boots" then
  60. tt_def.groups.armor_feet=1
  61. elseif tool == "shields" then
  62. tt_def.groups.armor_shield=1
  63. end
  64. toolname=minerdream.modname..":"..tool.."_"..i
  65. armor:register_armor(toolname,tt_def)
  66. end
  67. end
  68. end
  69. end