read_config.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. local has_value = minerdream.has_value
  2. local ore_cols={
  3. col_num={"crack"},
  4. groups_num={"has_dust","has_block","in_desert"}}
  5. local miner_definition = minerdream.import_csv(minerdream.path.."/ores.txt",ore_cols)
  6. if miner_definition["default"] ~= nil then
  7. default_ore = miner_definition["default"]
  8. local test_values = {}
  9. -- check, which numeric columns exist in default entry
  10. for i,d in pairs(ore_cols.col_num) do
  11. if default_ore[d] ~= nil then
  12. table.insert(test_values,1,d)
  13. end
  14. end
  15. -- check for each crop, if value can be copied from default entry
  16. for i,tdef in pairs(miner_definition) do
  17. if tdef.name ~= default_ore.name then
  18. for j,colu in pairs(test_values) do
  19. if tdef[colu] == nil then
  20. miner_definition[tdef.name][colu] = default_ore[colu]
  21. end
  22. end
  23. end
  24. end
  25. end
  26. for i,tdef in pairs(miner_definition) do
  27. if i ~= "default" then
  28. if tdef.crack ~= nil then
  29. ore_def={description=tdef.name.." ore",
  30. name=minerdream.modname..":stone_with_"..tdef.name,
  31. groups={cracky=tdef.crack},
  32. tiles={"default_stone.png^"..minerdream.modname.."_"..tdef.name.."_ore.png"},
  33. drop=minerdream.modname..":"..tdef.name.."_lump",
  34. sound=default.node_sound_stone_defaults(),
  35. }
  36. local to_override = false
  37. if tdef.overrides ~= nil then
  38. if minetest.registered_nodes[tdef.overrides] ~= nil then
  39. temp_def=minetest.registered_nodes[tdef.overrides]
  40. ore_def.name=tdef.overrides
  41. ore_def.drop=temp_def.drop
  42. to_override = true
  43. end
  44. end
  45. if minerdream.items[i] == nil then
  46. minerdream.items[i] = {ore_def = ore_def}
  47. else
  48. minerdream.items[i].ore_def=ore_def
  49. end
  50. if to_override then
  51. local ore_name=ore_def.name
  52. ore_def.name=nil
  53. minetest.override_item(ore_name,ore_def)
  54. else
  55. minetest.register_node(ore_def.name,ore_def)
  56. end
  57. if tdef.in_desert then
  58. desertore_def=table.copy(ore_def)
  59. desertore_def.name=minerdream.modname..":desertstone_with_"..tdef.name
  60. desertore_def.tiles={"default_desert_stone.png^"..minerdream.modname.."_"..tdef.name.."_ore.png"}
  61. if minerdream.items[i] == nil then
  62. minerdream.items[i] = {desertore_def = desertore_def}
  63. else
  64. minerdream.items[i].desertore_def=desertore_def
  65. end
  66. minetest.register_node(desertore_def.name,desertore_def)
  67. end
  68. end
  69. end
  70. end
  71. --[[
  72. minetest.register_node(itemname, {
  73. -- description = S(element.." ore"),
  74. description = element.." ore",
  75. tiles = {"default_"..stonename:gsub("desert","desert_")..".png^minerdream_"..element.."_ore.png"},
  76. groups = {cracky = crack},
  77. drop = modname:gsub(":","")..':'..element..'_lump',
  78. sounds = default.node_sound_stone_defaults(),
  79. })
  80. ]]