Version 0.41.3
[MineClone/MineClone2/MineClone2-Fixes.git] / mods / ENTITIES / drippingwater / init.lua
blob8e3ef4c181baa0993b5e7ba844c30a5ae2747eac
1 --Dripping Water Mod
2 --by kddekadenz
4 -- License of code, textures & sounds: CC0
6 --Drop entities
8 --water
10 local water_tex = "default_water_source_animated.png^[verticalframe:16:0"
11 minetest.register_entity("drippingwater:drop_water", {
12 hp_max = 1,
13 physical = true,
14 collide_with_objects = false,
15 collisionbox = {0,0,0,0,0,0},
16 visual = "cube",
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)
24 end,
26 on_step = function(self, dtime)
27 local k = math.random(1,222)
28 local ownpos = self.object:getpos()
30 if k==1 then
31 self.object:setacceleration({x=0, y=-5, z=0})
32 end
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})
36 end
38 if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
39 self.object:remove()
40 minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
41 end
42 end,
46 --lava
48 local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0"
49 minetest.register_entity("drippingwater:drop_lava", {
50 hp_max = 1,
51 physical = true,
52 collide_with_objects = false,
53 collisionbox = {0,0,0,0,0,0},
54 visual = "cube",
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)
62 end,
64 on_step = function(self, dtime)
65 local k = math.random(1,222)
66 local ownpos = self.object:getpos()
68 if k==1 then
69 self.object:setacceleration({x=0, y=-5, z=0})
70 end
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})
74 end
77 if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
78 self.object:remove()
79 minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
80 end
81 end,
86 --Create drop
88 minetest.register_abm(
90 label = "Create water drops",
91 nodenames = {"group:solid"},
92 neighbors = {"group:water"},
93 interval = 2,
94 chance = 22,
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")
101 end,
104 --Create lava drop
106 minetest.register_abm(
108 label = "Create lava drops",
109 nodenames = {"group:solid"},
110 neighbors = {"group:lava"},
111 interval = 2,
112 chance = 22,
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")
119 end,