mirror of
https://git.minetest.land/Mineclonia/Mineclonia.git
synced 2024-11-24 19:05:10 +00:00
Fix crash with non-player objects when adding player_physics attributes to object.
This commit is contained in:
parent
7dc36368b0
commit
70fd9db0c3
1 changed files with 3 additions and 3 deletions
|
@ -50,29 +50,29 @@ function mcl_potions.healing_func(player, hp)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_potions.swiftness_func(player, factor, duration)
|
function mcl_potions.swiftness_func(player, factor, duration)
|
||||||
|
if not player:get_meta() then return false end
|
||||||
playerphysics.add_physics_factor(player, "speed", "swiftness", factor)
|
playerphysics.add_physics_factor(player, "speed", "swiftness", factor)
|
||||||
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "speed", "swiftness") end )
|
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "speed", "swiftness") end )
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_potions.leaping_func(player, factor, duration)
|
function mcl_potions.leaping_func(player, factor, duration)
|
||||||
|
if player:get_meta() then return false end
|
||||||
playerphysics.add_physics_factor(player, "jump", "leaping", factor)
|
playerphysics.add_physics_factor(player, "jump", "leaping", factor)
|
||||||
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "jump", "leaping") end )
|
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "jump", "leaping") end )
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_potions.weakness_func(player, factor, duration)
|
function mcl_potions.weakness_func(player, factor, duration)
|
||||||
player:set_attribute("weakness", tostring(factor))
|
player:set_attribute("weakness", tostring(factor))
|
||||||
print(player:get_player_name().." ".."weakness = "..player:get_attribute("weakness"))
|
-- print(player:get_player_name().." ".."weakness = "..player:get_attribute("weakness"))
|
||||||
minetest.after(duration, function() player:set_attribute("weakness", tostring(0)) end )
|
minetest.after(duration, function() player:set_attribute("weakness", tostring(0)) end )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function mcl_potions.poison_func(player, factor, duration)
|
function mcl_potions.poison_func(player, factor, duration)
|
||||||
for i=1,math.floor(duration/factor) do
|
for i=1,math.floor(duration/factor) do
|
||||||
minetest.after(i*factor, function() player:set_hp(player:get_hp() - 1) end)
|
minetest.after(i*factor, function() player:set_hp(player:get_hp() - 1) end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function mcl_potions.regeneration_func(player, factor, duration)
|
function mcl_potions.regeneration_func(player, factor, duration)
|
||||||
for i=1,math.floor(duration/factor) do
|
for i=1,math.floor(duration/factor) do
|
||||||
minetest.after(i*factor, function()
|
minetest.after(i*factor, function()
|
||||||
|
|
Loading…
Reference in a new issue