update abms and fix snowball entity, thanks to crabman77

This commit is contained in:
HybridDog 2015-12-30 10:31:23 +01:00
parent 0e52c53452
commit d8d79655af
2 changed files with 45 additions and 37 deletions

View File

@ -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
minetest.register_abm({
@ -108,27 +95,29 @@ minetest.register_abm({
interval = 20,
chance = 4,
action = function(pos, node)
if node.param2 > 0 then
for l = 0,1 do
for i = -1,1,2 do
for _,p in pairs({
{x=pos.x+i, z=pos.z-l*i},
{x=pos.x+l*i, z=pos.z+i}
}) do
if math.random(2) == 2 then
p.y = pos.y
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
if node.param2 == 0 then
return
end
for l = 0,1 do
for i = -1,1,2 do
for _,p in pairs({
{x=pos.x+i, z=pos.z-l*i},
{x=pos.x+l*i, z=pos.z+i}
}) do
if math.random(2) == 2 then
p.y = pos.y
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
if math.random(8) == 8 then
minetest.add_node(pos, {name="default:water_source"})
else
minetest.add_node(pos, {name="default:ice", param2 = 0})
end
end
if math.random(8) == 8 then
minetest.add_node(pos, {name="default:water_source"})
else
node.param2 = 0
minetest.add_node(pos, node)
end
end,
})
@ -141,6 +130,7 @@ minetest.register_abm({
neighbors = {"snow:moss"},
interval = 20,
chance = 6,
catch_up = false,
action = function(pos, node)
node.name = "default:mossycobble"
minetest.add_node(pos, node)
@ -172,10 +162,10 @@ minetest.register_abm({
-- This finds the sapling under the grown tree. ~ LazyJ
if minetest.get_node(pos).name == "snow:sapling_pine" then
-- 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
-- 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
})
@ -206,3 +196,17 @@ minetest.register_abm({
--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,
})

View File

@ -124,6 +124,7 @@ function snow_snowball_ENTITY.on_step(self, dtime)
if self.timer > 600 then
-- 10 minutes are too long for a snowball to fly somewhere
self.object:remove()
return
end
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
if v ~= self.object then
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 ~= "snow:snowball_entity" then
if self.thrower then
v:punch(minetest.get_player_by_name(self.thrower), 1, {full_punch_interval=1, damage_groups = {fleshy=1}})
end
and entity_name ~= "gauges:hp_bar" then
v:punch(
(self.thrower and minetest.get_player_by_name(self.thrower))
or self.object,
1,
{full_punch_interval=1, damage_groups = {fleshy=1}}
)
spawn_falling_node(pos, {name = "default:snow"})
self.object:remove()
return