init.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. -- internationalization boilerplate
  2. local MP = minetest.get_modpath(minetest.get_current_modname())
  3. local S, NS = dofile(MP.."/intllib.lua")
  4. -- MCL2 compatibility
  5. local moditems = {}
  6. if core.get_modpath("mcl_core") and mcl_core then -- means MineClone 2 is loaded, this is its core mod
  7. moditems.IRON_ITEM = "mcl_core:iron_ingot" -- MCL iron
  8. else -- fallback, assume default (MineTest Game) is loaded, otherwise it will error anyway here.
  9. moditems.IRON_ITEM = "default:steel_ingot" -- MCL iron
  10. end
  11. local pontoons_override_logs = minetest.settings:get_bool("pontoons_override_logs") -- default false
  12. local pontoons_override_wood = minetest.settings:get_bool("pontoons_override_wood") -- default false
  13. local pontoons_wood_pontoons = minetest.settings:get_bool("pontoons_wood_pontoons")
  14. if pontoons_wood_pontoons == nil then pontoons_wood_pontoons = true end -- default true
  15. local pontoons_steel_pontoons = minetest.settings:get_bool("pontoons_steel_pontoons")
  16. if pontoons_steel_pontoons == nil then pontoons_steel_pontoons = true end -- default true
  17. local default_modpath = minetest.get_modpath("default")
  18. if pontoons_override_logs or pontoons_override_wood then
  19. local override_def = {liquids_pointable = true}
  20. for node_name, node_def in pairs(minetest.registered_nodes) do
  21. if pontoons_override_logs and minetest.get_item_group(node_name, "tree") > 0 then
  22. minetest.override_item(node_name, override_def)
  23. end
  24. if pontoons_override_wood and minetest.get_item_group(node_name, "wood") > 0 then
  25. minetest.override_item(node_name, override_def)
  26. end
  27. end
  28. end
  29. if pontoons_wood_pontoons then
  30. local default_sound
  31. local wood_burn_time
  32. if default_modpath then
  33. default_sound = default.node_sound_wood_defaults()
  34. wood_burn_time = minetest.get_craft_result({method="fuel", width=1, items={ItemStack("group:wood")}}).time
  35. end
  36. if not wood_burn_time then wood_burn_time = 7 end
  37. minetest.register_node("pontoons:wood_pontoon", {
  38. description = S("Wood Pontoon"),
  39. _doc_items_longdesc = S("A hollow wooden block designed to be built on the surface of liquids."),
  40. tiles = {"pontoon_wood.png"},
  41. paramtype2 = "facedir",
  42. place_param2 = 0,
  43. is_ground_content = false,
  44. liquids_pointable = true,
  45. groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2, wood = 1},
  46. sounds = default_sound,
  47. })
  48. -- modify recipe, if "airtank" mod is loaded as it has similar recipe and conflicts with pontoons.
  49. if core.get_modpath("airtanks") and airtanks then
  50. minetest.register_craft({
  51. output = 'pontoons:wood_pontoon 4',
  52. recipe = {
  53. {"group:wood","group:wood","group:wood"},
  54. {"","",""},
  55. {"","","group:wood"},
  56. }
  57. })
  58. else
  59. minetest.register_craft({
  60. output = 'pontoons:wood_pontoon 4',
  61. recipe = {
  62. {"","group:wood",""},
  63. {"group:wood","","group:wood"},
  64. {"","group:wood",""},
  65. }
  66. })
  67. end
  68. minetest.register_craft({
  69. type = "fuel",
  70. recipe = "pontoons:wood_pontoon",
  71. burntime = wood_burn_time,
  72. })
  73. end
  74. if pontoons_steel_pontoons then
  75. local default_sound
  76. if default_modpath then
  77. if default.node_sound_metal_defaults then
  78. default_sound = default.node_sound_metal_defaults()
  79. else
  80. default_sound = default.node_sound_wood_defaults()
  81. end
  82. end
  83. minetest.register_node("pontoons:steel_pontoon", {
  84. description = S("Steel Pontoon"),
  85. _doc_items_longdesc = S("A hollow steel block designed to be built on the surface of liquids. Magma-safe."),
  86. is_ground_content = false,
  87. tiles = {"pontoon_steel.png"},
  88. liquids_pointable = true,
  89. is_ground_content = false,
  90. groups = {cracky = 1, level = 2},
  91. sounds = default_sound,
  92. })
  93. if default_modpath then
  94. if core.get_modpath("airtanks") and airtanks then
  95. minetest.register_craft({
  96. output = 'pontoons:steel_pontoon',
  97. recipe = {
  98. {"",moditems.IRON_ITEM,""},
  99. {moditems.IRON_ITEM,"",moditems.IRON_ITEM},
  100. {"","",moditems.IRON_ITEM},
  101. }
  102. })
  103. else
  104. minetest.register_craft({
  105. output = 'pontoons:steel_pontoon',
  106. recipe = {
  107. {"",moditems.IRON_ITEM,""},
  108. {moditems.IRON_ITEM,"",moditems.IRON_ITEM},
  109. {"",moditems.IRON_ITEM,""},
  110. }
  111. })
  112. end
  113. end
  114. end