[drippingwater] fix warnings

This commit is contained in:
AFCMS 2021-05-25 00:54:12 +02:00
parent be9fff4fe2
commit 0d13e1ffdd
1 changed files with 37 additions and 48 deletions

View File

@ -1,6 +1,8 @@
--Dripping Water Mod --Dripping Water Mod
--by kddekadenz --by kddekadenz
local math = math
-- License of code, textures & sounds: CC0 -- License of code, textures & sounds: CC0
--Drop entities --Drop entities
@ -20,23 +22,18 @@ minetest.register_entity("drippingwater:drop_water", {
spritediv = {x=1, y=1}, spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
static_save = false, static_save = false,
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.object:set_sprite({x=0,y=0}, 1, 1, true) self.object:set_sprite({x=0,y=0}, 1, 1, true)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local k = math.random(1,222) local k = math.random(1,222)
local ownpos = self.object:get_pos() local ownpos = self.object:get_pos()
if k==1 then if k==1 then
self.object:set_acceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then 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}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
self.object:remove() self.object:remove()
minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) minetest.sound_play({name="drippingwater_drip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
@ -61,24 +58,18 @@ minetest.register_entity("drippingwater:drop_lava", {
spritediv = {x=1, y=1}, spritediv = {x=1, y=1},
initial_sprite_basepos = {x=0, y=0}, initial_sprite_basepos = {x=0, y=0},
static_save = false, static_save = false,
on_activate = function(self, staticdata) on_activate = function(self, staticdata)
self.object:set_sprite({x=0,y=0}, 1, 0, true) self.object:set_sprite({x=0,y=0}, 1, 0, true)
end, end,
on_step = function(self, dtime) on_step = function(self, dtime)
local k = math.random(1,222) local k = math.random(1,222)
local ownpos = self.object:get_pos() local ownpos = self.object:get_pos()
if k == 1 then if k == 1 then
self.object:set_acceleration({x=0, y=-5, z=0}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y +0.5, z=ownpos.z}).name == "air" then 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}) self.object:set_acceleration({x=0, y=-5, z=0})
end end
if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then if minetest.get_node({x=ownpos.x, y=ownpos.y -0.5, z=ownpos.z}).name ~= "air" then
self.object:remove() self.object:remove()
minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true) minetest.sound_play({name="drippingwater_lavadrip"}, {pos = ownpos, gain = 0.5, max_hear_distance = 8}, true)
@ -90,16 +81,15 @@ minetest.register_entity("drippingwater:drop_lava", {
--Create drop --Create drop
minetest.register_abm( minetest.register_abm({
{
label = "Create water drops", label = "Create water drops",
nodenames = {"group:opaque", "group:leaves"}, nodenames = {"group:opaque", "group:leaves"},
neighbors = {"group:water"}, neighbors = {"group:water"},
interval = 2, interval = 2,
chance = 22, chance = 22,
action = function(pos) 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 if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "water") ~= 0
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
local i = math.random(-45,45) / 100 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") minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_water")
end end
@ -108,16 +98,15 @@ minetest.register_abm(
--Create lava drop --Create lava drop
minetest.register_abm( minetest.register_abm({
{
label = "Create lava drops", label = "Create lava drops",
nodenames = {"group:opaque"}, nodenames = {"group:opaque"},
neighbors = {"group:lava"}, neighbors = {"group:lava"},
interval = 2, interval = 2,
chance = 22, chance = 22,
action = function(pos) 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 if minetest.get_item_group(minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name, "lava") ~= 0
minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then and minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name == "air" then
local i = math.random(-45,45) / 100 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") minetest.add_entity({x=pos.x + i, y=pos.y - 0.501, z=pos.z + i}, "drippingwater:drop_lava")
end end