fluid.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. -- LUALOCALS < ---------------------------------------------------------
  2. local minetest, nodecore, pairs, vector
  3. = minetest, nodecore, pairs, vector
  4. -- LUALOCALS > ---------------------------------------------------------
  5. local modname = minetest.get_current_modname()
  6. local wetdef = {
  7. description = "Flux",
  8. tiles = {modname .. "_base.png"},
  9. special_tiles = {modname .. "_base.png", modname .. "_base.png"},
  10. paramtype = "light",
  11. alpha = 64,
  12. liquid_viscosity = 0,
  13. liquid_renewable = false,
  14. liquid_range = 2,
  15. liquid_alternative_flowing = modname .. ":flux_flowing",
  16. liquid_alternative_source = modname .. ":flux_source",
  17. pointable = false,
  18. walkable = false,
  19. buildable_to = true,
  20. light_source = 10,
  21. sunlight_propagates = true,
  22. air_pass = true,
  23. drowning = 0,
  24. groups = {
  25. lux_emit = 16,
  26. lux_fluid = 1,
  27. stack_as_node = 1
  28. },
  29. post_effect_color = {a = 64, r = 251, g = 241, b = 143}
  30. }
  31. minetest.register_node(modname .. ":flux_source", nodecore.underride({
  32. drawtype = "liquid",
  33. liquidtype = "source"
  34. }, wetdef))
  35. minetest.register_node(modname .. ":flux_flowing", nodecore.underride({
  36. drawtype = "flowingliquid",
  37. liquidtype = "flowing",
  38. paramtype2 = "flowingliquid"
  39. }, wetdef))
  40. local outdirs = {}
  41. for _, v in pairs(nodecore.dirs()) do
  42. if v.y <= 0 then
  43. outdirs[#outdirs + 1] = v
  44. end
  45. end
  46. nodecore.register_limited_abm({
  47. label = "lux flow leak",
  48. interval = 1,
  49. chance = 2,
  50. limited_max = 100,
  51. nodenames = {"group:lux_cobble_max"},
  52. action = function(pos)
  53. for _, v in pairs(outdirs) do
  54. local p = vector.add(pos, v)
  55. if minetest.get_node(p).name ~= modname .. ":flux_source"
  56. and nodecore.buildable_to(p) then
  57. minetest.set_node(p, {name = modname .. ":flux_source"})
  58. end
  59. end
  60. end
  61. })
  62. local indirs = {}
  63. for _, v in pairs(nodecore.dirs()) do
  64. if v.y >= 0 then
  65. indirs[#indirs + 1] = v
  66. end
  67. end
  68. nodecore.register_limited_abm({
  69. label = "lux flow ebb",
  70. interval = 1,
  71. chance = 2,
  72. limited_max = 100,
  73. nodenames = {modname .. ":flux_source"},
  74. action = function(pos)
  75. for _, v in pairs(indirs) do
  76. local p = vector.add(pos, v)
  77. local def = minetest.registered_nodes[minetest.get_node(p).name]
  78. if def and def.groups and def.groups.lux_cobble_max then return end
  79. end
  80. return minetest.set_node(pos, {name = modname .. ":flux_flowing", param2 = 7})
  81. end
  82. })