2017-01-06 04:45:04 +03:00
|
|
|
--Dripping Water Mod
|
|
|
|
--by kddekadenz
|
|
|
|
|
2021-05-25 01:54:12 +03:00
|
|
|
local math = math
|
|
|
|
|
2017-01-06 04:45:04 +03:00
|
|
|
-- License of code, textures & sounds: CC0
|
|
|
|
|
|
|
|
--Drop entities
|
|
|
|
|
|
|
|
--water
|
|
|
|
|
2017-07-17 13:20:15 +03:00
|
|
|
local water_tex = "default_water_source_animated.png^[verticalframe:16:0"
|
2017-01-06 04:45:04 +03:00
|
|
|
minetest.register_entity("drippingwater:drop_water", {
|
2017-01-06 04:51:12 +03:00
|
|
|
hp_max = 1,
|
2017-01-06 04:45:04 +03:00
|
|
|
physical = true,
|
2017-01-06 05:06:46 +03:00
|
|
|
collide_with_objects = false,
|
2019-03-08 05:05:27 +03:00
|
|
|
collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025},
|
2019-03-07 05:53:06 +03:00
|
|
|
pointable = false,
|
2017-01-06 04:45:04 +03:00
|
|
|
visual = "cube",
|
|
|
|
visual_size = {x=0.05, y=0.1},
|
2017-07-17 13:20:15 +03:00
|
|
|
textures = {water_tex, water_tex, water_tex, water_tex, water_tex, water_tex},
|
2017-01-06 04:45:04 +03:00
|
|
|
spritediv = {x=1, y=1},
|
|
|
|
initial_sprite_basepos = {x=0, y=0},
|
2019-03-10 06:22:19 +03:00
|
|
|
static_save = false,
|
2017-01-06 04:45:04 +03:00
|
|
|
on_activate = function(self, staticdata)
|
2019-03-06 06:38:57 +03:00
|
|
|
self.object:set_sprite({x=0,y=0}, 1, 1, true)
|
2017-01-06 04:45:04 +03:00
|
|
|
end,
|
|
|
|
on_step = function(self, dtime)
|
2021-05-25 01:54:12 +03:00
|
|
|
local k = math.random(1,222)
|
|
|
|
local ownpos = self.object:get_pos()
|
|
|
|
if k==1 then
|
|
|
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
|
|
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
2017-01-06 04:56:53 +03:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
2021-05-25 01:54:12 +03:00
|
|
|
self.object:remove()
|
|
|
|
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
2017-01-06 04:45:04 +03:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
--lava
|
|
|
|
|
2017-07-17 13:20:15 +03:00
|
|
|
local lava_tex = "default_lava_source_animated.png^[verticalframe:16:0"
|
2017-01-06 04:45:04 +03:00
|
|
|
minetest.register_entity("drippingwater:drop_lava", {
|
2017-01-06 04:51:12 +03:00
|
|
|
hp_max = 1,
|
2017-01-06 04:45:04 +03:00
|
|
|
physical = true,
|
2017-01-06 05:06:46 +03:00
|
|
|
collide_with_objects = false,
|
2019-03-08 05:05:27 +03:00
|
|
|
collisionbox = {-0.025,-0.05,-0.025,0.025,-0.01,0.025},
|
|
|
|
glow = math.max(7, minetest.registered_nodes["mcl_core:lava_source"].light_source - 3),
|
|
|
|
pointable = false,
|
2017-01-06 04:45:04 +03:00
|
|
|
visual = "cube",
|
|
|
|
visual_size = {x=0.05, y=0.1},
|
2017-07-17 13:20:15 +03:00
|
|
|
textures = {lava_tex, lava_tex, lava_tex, lava_tex, lava_tex, lava_tex},
|
2017-01-06 04:45:04 +03:00
|
|
|
spritediv = {x=1, y=1},
|
|
|
|
initial_sprite_basepos = {x=0, y=0},
|
2019-03-10 06:22:19 +03:00
|
|
|
static_save = false,
|
2017-01-06 04:45:04 +03:00
|
|
|
on_activate = function(self, staticdata)
|
2019-03-06 06:38:57 +03:00
|
|
|
self.object:set_sprite({x=0,y=0}, 1, 0, true)
|
2017-01-06 04:45:04 +03:00
|
|
|
end,
|
|
|
|
on_step = function(self, dtime)
|
2021-05-25 01:54:12 +03:00
|
|
|
local k = math.random(1,222)
|
|
|
|
local ownpos = self.object:get_pos()
|
|
|
|
if k == 1 then
|
|
|
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then
|
|
|
|
self.object:set_acceleration({x=0, y=-5, z=0})
|
|
|
|
end
|
2017-01-06 04:56:53 +03:00
|
|
|
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
|
2021-05-25 01:54:12 +03:00
|
|
|
self.object:remove()
|
|
|
|
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
|
2017-01-06 04:45:04 +03:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--Create drop
|
|
|
|
|
2021-05-25 01:54:12 +03:00
|
|
|
minetest.register_abm({
|
2017-05-15 01:45:54 +03:00
|
|
|
label = "Create water drops",
|
2020-02-23 18:17:04 +03:00
|
|
|
nodenames = {"group:opaque", "group:leaves"},
|
2017-01-06 04:45:04 +03:00
|
|
|
neighbors = {"group:water"},
|
2021-05-25 01:54:12 +03:00
|
|
|
interval = 2,
|
|
|
|
chance = 22,
|
|
|
|
action = function(pos)
|
|
|
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0
|
|
|
|
and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
2017-05-20 01:38:10 +03:00
|
|
|
local i = math.random(-45,45) / 100
|
|
|
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
|
2017-01-06 04:45:04 +03:00
|
|
|
end
|
2021-05-25 01:54:12 +03:00
|
|
|
end,
|
2017-01-06 04:45:04 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
--Create lava drop
|
|
|
|
|
2021-05-25 01:54:12 +03:00
|
|
|
minetest.register_abm({
|
2017-05-15 01:45:54 +03:00
|
|
|
label = "Create lava drops",
|
2020-02-23 18:17:04 +03:00
|
|
|
nodenames = {"group:opaque"},
|
2017-01-06 04:45:04 +03:00
|
|
|
neighbors = {"group:lava"},
|
2021-05-25 01:54:12 +03:00
|
|
|
interval = 2,
|
|
|
|
chance = 22,
|
|
|
|
action = function(pos)
|
|
|
|
if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0
|
|
|
|
and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
|
2017-05-20 01:38:10 +03:00
|
|
|
local i = math.random(-45,45) / 100
|
|
|
|
minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
|
2017-01-06 04:45:04 +03:00
|
|
|
end
|
2021-05-25 01:54:12 +03:00
|
|
|
end,
|
|
|
|
})
|