2017-01-06 01:45:04 +00:00
|
|
|
--Dripping Water Mod
|
|
|
|
--by kddekadenz
|
|
|
|
|
|
|
|
-- License of code, textures & sounds: CC0
|
|
|
|
|
|
|
|
--Drop entities
|
|
|
|
|
|
|
|
--water
|
|
|
|
|
|
|
|
minetest.register_entity("drippingwater:drop_water", {
|
2017-01-06 01:51:12 +00:00
|
|
|
hp_max = 1,
|
2017-01-06 01:45:04 +00:00
|
|
|
physical = true,
|
2017-01-06 02:06:46 +00:00
|
|
|
collide_with_objects = false,
|
2017-01-06 01:45:04 +00:00
|
|
|
collisionbox = {0,0,0,0,0,0},
|
|
|
|
visual = "cube",
|
|
|
|
visual_size = {x=0.05, y=0.1},
|
|
|
|
textures = {"default_water.png","default_water.png","default_water.png","default_water.png", "default_water.png", "default_water.png"},
|
|
|
|
spritediv = {x=1, y=1},
|
|
|
|
initial_sprite_basepos = {x=0, y=0},
|
|
|
|
|
|
|
|
on_activate = function(self, staticdata)
|
|
|
|
self.object:setsprite({x=0,y=0}, 1, 1, true)
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_step = function(self, dtime)
|
|
|
|
local k = math.random(1,222)
|
|
|
|
local ownpos = self.object:getpos()
|
|
|
|
|
|
|
|
if k==1 then
|
|
|
|
self.object:setacceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
self.object:setacceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
self.object:remove()
|
|
|
|
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
--lava
|
|
|
|
|
|
|
|
minetest.register_entity("drippingwater:drop_lava", {
|
2017-01-06 01:51:12 +00:00
|
|
|
hp_max = 1,
|
2017-01-06 01:45:04 +00:00
|
|
|
physical = true,
|
2017-01-06 02:06:46 +00:00
|
|
|
collide_with_objects = false,
|
2017-01-06 01:45:04 +00:00
|
|
|
collisionbox = {0,0,0,0,0,0},
|
|
|
|
visual = "cube",
|
|
|
|
visual_size = {x=0.05, y=0.1},
|
|
|
|
textures = {"default_lava.png","default_lava.png","default_lava.png","default_lava.png", "default_lava.png", "default_lava.png"},
|
|
|
|
spritediv = {x=1, y=1},
|
|
|
|
initial_sprite_basepos = {x=0, y=0},
|
|
|
|
|
|
|
|
on_activate = function(self, staticdata)
|
|
|
|
self.object:setsprite({x=0,y=0}, 1, 0, true)
|
|
|
|
end,
|
|
|
|
|
|
|
|
on_step = function(self, dtime)
|
|
|
|
local k = math.random(1,222)
|
|
|
|
local ownpos = self.object:getpos()
|
|
|
|
|
|
|
|
if k==1 then
|
|
|
|
self.object:setacceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
self.object:setacceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
self.object:remove()
|
|
|
|
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Create drop
|
|
|
|
|
|
|
|
minetest.register_abm(
|
2017-02-27 17:53:17 +00:00
|
|
|
{nodenames = {"group:solid"},
|
2017-01-06 01:45:04 +00:00
|
|
|
neighbors = {"group:water"},
|
|
|
|
interval = 2,
|
|
|
|
chance = 22,
|
|
|
|
action = function(pos)
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=pos.x, y=pos.y -1, z=pos.z}).name == "air" and
|
|
|
|
minetest.get_node({x=pos.x, y=pos.y -2, z=pos.z}).name == "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
local i = math.random(-45,45) / 100
|
2017-01-06 01:56:53 +00:00
|
|
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
|
2017-01-06 01:45:04 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
--Create lava drop
|
|
|
|
|
|
|
|
minetest.register_abm(
|
2017-02-27 17:53:17 +00:00
|
|
|
{nodenames = {"group:solid"},
|
2017-01-06 01:45:04 +00:00
|
|
|
neighbors = {"group:lava"},
|
|
|
|
interval = 2,
|
|
|
|
chance = 22,
|
|
|
|
action = function(pos)
|
2017-01-06 01:56:53 +00:00
|
|
|
if minetest.get_node({x=pos.x, y=pos.y -1, z=pos.z}).name == "air" and
|
|
|
|
minetest.get_node({x=pos.x, y=pos.y -2, z=pos.z}).name == "air" then
|
2017-01-06 01:45:04 +00:00
|
|
|
local i = math.random(-45,45) / 100
|
2017-01-06 01:56:53 +00:00
|
|
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
|
2017-01-06 01:45:04 +00:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|