1
0
Fork 0

Fix crash with non-player objects when adding player_physics attributes to object.

This commit is contained in:
Brandon 2020-06-18 20:22:44 -04:00
parent 7dc36368b0
commit 70fd9db0c3
1 changed files with 3 additions and 3 deletions

View File

@ -50,29 +50,29 @@ function mcl_potions.healing_func(player, hp)
end
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)
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "speed", "swiftness") end )
end
function mcl_potions.leaping_func(player, factor, duration)
if player:get_meta() then return false end
playerphysics.add_physics_factor(player, "jump", "leaping", factor)
minetest.after(duration, function() playerphysics.remove_physics_factor(player, "jump", "leaping") end )
end
function mcl_potions.weakness_func(player, factor, duration)
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 )
end
function mcl_potions.poison_func(player, factor, duration)
for i=1,math.floor(duration/factor) do
minetest.after(i*factor, function() player:set_hp(player:get_hp() - 1) end)
end
end
function mcl_potions.regeneration_func(player, factor, duration)
for i=1,math.floor(duration/factor) do
minetest.after(i*factor, function()