4 -- License of code, textures & sounds: CC0
10 local water_tex
= "default_water_source_animated.png^[verticalframe:16:0"
11 minetest
.register_entity("drippingwater:drop_water", {
14 collide_with_objects
= false,
15 collisionbox
= {0,0,0,0,0,0},
17 visual_size
= {x
=0.05, y
=0.1},
18 textures
= {water_tex
, water_tex
, water_tex
, water_tex
, water_tex
, water_tex
},
19 spritediv
= {x
=1, y
=1},
20 initial_sprite_basepos
= {x
=0, y
=0},
22 on_activate
= function(self
, staticdata
)
23 self
.object
:setsprite({x
=0,y
=0}, 1, 1, true)
26 on_step
= function(self
, dtime
)
27 local k
= math
.random(1,222)
28 local ownpos
= self
.object
:getpos()
31 self
.object
:setacceleration({x
=0, y
=-5, z
=0})
34 if minetest
.get_node({x
=ownpos
.x
, y
=ownpos
.y
+0.5, z
=ownpos
.z
}).name
== "air" then
35 self
.object
:setacceleration({x
=0, y
=-5, z
=0})
38 if minetest
.get_node({x
=ownpos
.x
, y
=ownpos
.y
-0.5, z
=ownpos
.z
}).name
~= "air" then
40 minetest
.sound_play({name
="drippingwater_drip"}, {pos
= ownpos
, gain
= 0.5, max_hear_distance
= 8})
48 local lava_tex
= "default_lava_source_animated.png^[verticalframe:16:0"
49 minetest
.register_entity("drippingwater:drop_lava", {
52 collide_with_objects
= false,
53 collisionbox
= {0,0,0,0,0,0},
55 visual_size
= {x
=0.05, y
=0.1},
56 textures
= {lava_tex
, lava_tex
, lava_tex
, lava_tex
, lava_tex
, lava_tex
},
57 spritediv
= {x
=1, y
=1},
58 initial_sprite_basepos
= {x
=0, y
=0},
60 on_activate
= function(self
, staticdata
)
61 self
.object
:setsprite({x
=0,y
=0}, 1, 0, true)
64 on_step
= function(self
, dtime
)
65 local k
= math
.random(1,222)
66 local ownpos
= self
.object
:getpos()
69 self
.object
:setacceleration({x
=0, y
=-5, z
=0})
72 if minetest
.get_node({x
=ownpos
.x
, y
=ownpos
.y
+0.5, z
=ownpos
.z
}).name
== "air" then
73 self
.object
:setacceleration({x
=0, y
=-5, z
=0})
77 if minetest
.get_node({x
=ownpos
.x
, y
=ownpos
.y
-0.5, z
=ownpos
.z
}).name
~= "air" then
79 minetest
.sound_play({name
="drippingwater_lavadrip"}, {pos
= ownpos
, gain
= 0.5, max_hear_distance
= 8})
88 minetest
.register_abm(
90 label
= "Create water drops",
91 nodenames
= {"group:solid"},
92 neighbors
= {"group:water"},
95 action
= function(pos
)
96 if minetest
.get_item_group(minetest
.get_node({x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}).name
, "water") ~= 0 and
97 minetest
.get_node({x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}).name
== "air" then
98 local i
= math
.random(-45,45) / 100
99 minetest
.add_entity({x
=pos
.x
+ i
, y
=pos
.y
- 0.501, z
=pos
.z
+ i
}, "drippingwater:drop_water")
106 minetest
.register_abm(
108 label
= "Create lava drops",
109 nodenames
= {"group:solid"},
110 neighbors
= {"group:lava"},
113 action
= function(pos
)
114 if minetest
.get_item_group(minetest
.get_node({x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}).name
, "lava") ~= 0 and
115 minetest
.get_node({x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
}).name
== "air" then
116 local i
= math
.random(-45,45) / 100
117 minetest
.add_entity({x
=pos
.x
+ i
, y
=pos
.y
- 0.501, z
=pos
.z
+ i
}, "drippingwater:drop_lava")