mirror of
https://github.com/Splizard/minetest-mod-snow.git
synced 2024-11-16 06:40:17 +01:00
update abms and fix snowball entity, thanks to crabman77
This commit is contained in:
parent
0e52c53452
commit
d8d79655af
68
src/abms.lua
68
src/abms.lua
|
@ -1,16 +1,3 @@
|
||||||
--Backwards Compatability.
|
|
||||||
minetest.register_abm({
|
|
||||||
nodenames = {"snow:snow1","snow:snow2","snow:snow3","gsnow4","snow:snow5","snow:snow6","snow:snow7","snow:snow8"},
|
|
||||||
interval = 1,
|
|
||||||
chance = 1,
|
|
||||||
action = function(pos, node)
|
|
||||||
minetest.add_node(pos, {name="default:snow"})
|
|
||||||
minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1))))
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
|
-- Added to change dirt_with_snow to dirt if covered with blocks that don't let light through (sunlight_propagates) or have a light paramtype and liquidtype combination. ~ LazyJ, 2014_03_08
|
||||||
|
|
||||||
minetest.register_abm({
|
minetest.register_abm({
|
||||||
|
@ -108,27 +95,29 @@ minetest.register_abm({
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 4,
|
chance = 4,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
if node.param2 > 0 then
|
if node.param2 == 0 then
|
||||||
for l = 0,1 do
|
return
|
||||||
for i = -1,1,2 do
|
end
|
||||||
for _,p in pairs({
|
for l = 0,1 do
|
||||||
{x=pos.x+i, z=pos.z-l*i},
|
for i = -1,1,2 do
|
||||||
{x=pos.x+l*i, z=pos.z+i}
|
for _,p in pairs({
|
||||||
}) do
|
{x=pos.x+i, z=pos.z-l*i},
|
||||||
if math.random(2) == 2 then
|
{x=pos.x+l*i, z=pos.z+i}
|
||||||
p.y = pos.y
|
}) do
|
||||||
if minetest.get_node(p).name == "default:water_source" then
|
if math.random(2) == 2 then
|
||||||
minetest.add_node(p,{name="default:ice", param2 = math.random(0,node.param2-1)})
|
p.y = pos.y
|
||||||
end
|
if minetest.get_node(p).name == "default:water_source" then
|
||||||
|
minetest.add_node(p,{name="default:ice", param2 = math.random(0,node.param2-1)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if math.random(8) == 8 then
|
end
|
||||||
minetest.add_node(pos, {name="default:water_source"})
|
if math.random(8) == 8 then
|
||||||
else
|
minetest.add_node(pos, {name="default:water_source"})
|
||||||
minetest.add_node(pos, {name="default:ice", param2 = 0})
|
else
|
||||||
end
|
node.param2 = 0
|
||||||
|
minetest.add_node(pos, node)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -141,6 +130,7 @@ minetest.register_abm({
|
||||||
neighbors = {"snow:moss"},
|
neighbors = {"snow:moss"},
|
||||||
interval = 20,
|
interval = 20,
|
||||||
chance = 6,
|
chance = 6,
|
||||||
|
catch_up = false,
|
||||||
action = function(pos, node)
|
action = function(pos, node)
|
||||||
node.name = "default:mossycobble"
|
node.name = "default:mossycobble"
|
||||||
minetest.add_node(pos, node)
|
minetest.add_node(pos, node)
|
||||||
|
@ -172,10 +162,10 @@ minetest.register_abm({
|
||||||
-- This finds the sapling under the grown tree. ~ LazyJ
|
-- This finds the sapling under the grown tree. ~ LazyJ
|
||||||
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
if minetest.get_node(pos).name == "snow:sapling_pine" then
|
||||||
-- This switches the sapling to a tree trunk. ~ LazyJ
|
-- This switches the sapling to a tree trunk. ~ LazyJ
|
||||||
minetest.set_node(pos, {name="default:pinetree"})
|
minetest.set_node(pos, {name="default:pinetree"})
|
||||||
-- This is more for testing but it may be useful info to some admins when
|
-- This is more for testing but it may be useful info to some admins when
|
||||||
-- grepping the server logs too. ~ LazyJ
|
-- grepping the server logs too. ~ LazyJ
|
||||||
minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos))
|
minetest.log("action", "A pine sapling grows into a tree at "..minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -206,3 +196,17 @@ minetest.register_abm({
|
||||||
--end
|
--end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--Backwards Compatability.
|
||||||
|
minetest.register_abm({
|
||||||
|
nodenames = {"snow:snow1","snow:snow2","snow:snow3","gsnow4","snow:snow5","snow:snow6","snow:snow7","snow:snow8"},
|
||||||
|
interval = 1,
|
||||||
|
chance = 1,
|
||||||
|
action = function(pos, node)
|
||||||
|
minetest.add_node(pos, {name="default:snow"})
|
||||||
|
minetest.set_node_level(pos, 7*(tonumber(node.name:sub(-1))))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -124,6 +124,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
||||||
if self.timer > 600 then
|
if self.timer > 600 then
|
||||||
-- 10 minutes are too long for a snowball to fly somewhere
|
-- 10 minutes are too long for a snowball to fly somewhere
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.physical then
|
if self.physical then
|
||||||
|
@ -164,12 +165,15 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
||||||
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
for _,v in pairs(minetest.get_objects_inside_radius(pos, 1.73)) do
|
||||||
if v ~= self.object then
|
if v ~= self.object then
|
||||||
local entity_name = v:get_entity_name()
|
local entity_name = v:get_entity_name()
|
||||||
if entity_name ~= "__builtin:item"
|
if entity_name ~= "snow:snowball_entity"
|
||||||
and entity_name ~= "__builtin:item"
|
and entity_name ~= "__builtin:item"
|
||||||
and entity_name ~= "snow:snowball_entity" then
|
and entity_name ~= "gauges:hp_bar" then
|
||||||
if self.thrower then
|
v:punch(
|
||||||
v:punch(minetest.get_player_by_name(self.thrower), 1, {full_punch_interval=1, damage_groups = {fleshy=1}})
|
(self.thrower and minetest.get_player_by_name(self.thrower))
|
||||||
end
|
or self.object,
|
||||||
|
1,
|
||||||
|
{full_punch_interval=1, damage_groups = {fleshy=1}}
|
||||||
|
)
|
||||||
spawn_falling_node(pos, {name = "default:snow"})
|
spawn_falling_node(pos, {name = "default:snow"})
|
||||||
self.object:remove()
|
self.object:remove()
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user