api.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. -- LUALOCALS < ---------------------------------------------------------
  2. local minetest, nodecore
  3. = minetest, nodecore
  4. -- LUALOCALS > ---------------------------------------------------------
  5. local modname = minetest.get_current_modname()
  6. function nodecore.register_concrete(def)
  7. def = nodecore.underride(def, {
  8. name = def.description:lower():gsub("%W", "_"),
  9. groups_powder = {
  10. falling_node = 1,
  11. falling_repose = 1,
  12. concrete_powder = 1
  13. },
  14. groups_wet = {concrete_wet = 1},
  15. swim_color = {a = 240, r = 32, g = 32, b = 32}
  16. })
  17. local basename = modname .. ":" .. def.name
  18. def.basename = basename
  19. if def.register_dry ~= false then
  20. minetest.register_node(":" .. basename, {
  21. description = def.description,
  22. tiles = {def.tile_powder},
  23. groups = def.groups_powder,
  24. crush_damage = 1,
  25. sounds = nodecore.sounds(def.sound),
  26. concrete_def = def
  27. })
  28. end
  29. if def.register_wet ~= false then
  30. local wetdef = {
  31. description = "Wet " .. def.description,
  32. tiles = {def.tile_wet},
  33. special_tiles = {def.tile_wet, def.tile_wet},
  34. paramtype = "light",
  35. liquid_viscosity = 15,
  36. liquid_renewable = false,
  37. liquid_range = 1,
  38. liquid_alternative_flowing = basename .. "_wet_flowing",
  39. liquid_alternative_source = basename .. "_wet_source",
  40. walkable = false,
  41. drowning = 2,
  42. post_effect_color = def.swim_color,
  43. groups = def.groups_wet,
  44. sounds = nodecore.sounds(def.sound),
  45. concrete_def = def
  46. }
  47. minetest.register_node(":" .. basename .. "_wet_source", nodecore.underride({
  48. liquidtype = "source",
  49. groups = {concrete_source = 1}
  50. }, wetdef))
  51. minetest.register_node(basename .. "_wet_flowing", nodecore.underride({
  52. drawtype = "flowingliquid",
  53. liquidtype = "flowing",
  54. paramtype2 = "flowingliquid",
  55. groups = {concrete_flow = 1}
  56. }, wetdef))
  57. end
  58. if def.craft_mix ~= false then
  59. nodecore.register_craft({
  60. label = "mix " .. def.name .. " (fail)",
  61. action = "pummel",
  62. priority = 2,
  63. toolgroups = {thumpy = 1},
  64. normal = {y = 1},
  65. indexkeys = def.craft_from_keys,
  66. nodes = {
  67. {
  68. match = def.craft_from
  69. },
  70. {
  71. x = 1,
  72. y = -1,
  73. match = {buildable_to = true}
  74. },
  75. {
  76. y = -1,
  77. match = "nc_fire:ash",
  78. replace = "air"
  79. }
  80. },
  81. before = function(pos)
  82. nodecore.item_disperse(pos, "nc_fire:lump_ash", 8)
  83. end
  84. })
  85. nodecore.register_craft({
  86. label = "mix " .. def.name,
  87. action = "pummel",
  88. priority = 1,
  89. toolgroups = {thumpy = 1},
  90. normal = {y = 1},
  91. indexkeys = def.craft_from_keys,
  92. nodes = {
  93. {
  94. match = def.craft_from,
  95. replace = "air"
  96. },
  97. {
  98. y = -1,
  99. match = "nc_fire:ash",
  100. replace = basename
  101. }
  102. }
  103. })
  104. end
  105. end