Change lump itemstrings
[minetest_pedology.git] / drip.lua
blob69bc8bc42ca0a05d0da5b0d1e923435d11597051
1 -- Water drips
2 -- Based on the Dripping Water Mod by kddekadenz
4 --Random
5 --TODO: Get proper random seed based on world seed or something like that
6 math.randomseed(4053633)
8 --Drop entities
9 minetest.register_entity("pedology:drop_water", {
10 hp_max = 2000,
11 physical = true,
12 collisionbox = {0,0,0,0,0,0},
13 visual = "cube",
14 visual_size = {x=0.05, y=0.1},
15 textures = {"pedology_water_fresh.png", "pedology_water_fresh.png", "pedology_water_fresh.png", "pedology_water_fresh.png", "pedology_water_fresh.png", "pedology_water_fresh.png"},
16 spritediv = {x=1, y=1},
17 initial_sprite_basepos = {x=0, y=0},
19 on_activate = function(self, staticdata)
20 self.object:setsprite({x=0,y=0}, 1, 1, true)
21 end,
23 on_step = function(self, dtime)
24 local k = math.random(1,222)
25 local ownpos = self.object:getpos()
27 if k==1 then
28 self.object:setacceleration({x=0, y=-5, z=0})
29 end
31 if minetest.env:get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
32 self.object:setacceleration({x=0, y=-5, z=0})
33 end
35 if minetest.env:get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
36 self.object:remove()
37 minetest.sound_play({name="pedology_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
38 end
39 end,
42 function pedology.create_drip(pos)
43 if minetest.env:get_node({x=pos.x, y=pos.y -1, z=pos.z}).name == "air" and
44 minetest.env:get_node({x=pos.x, y=pos.y -2, z=pos.z}).name == "air" then
45 local i = math.random(-45,45) / 100
46 minetest.env:add_entity({x=pos.x + i, y=pos.y - 0.5, z=pos.z + i}, "pedology:drop_water")
47 end
48 end