forked from VoxeLibre/VoxeLibre
Fix lingering potion timer.
This commit is contained in:
parent
2a29ec7827
commit
79e7f6849f
|
@ -12,25 +12,19 @@ local function add_lingering_effect(pos, color, def)
|
|||
|
||||
lingering_effect_at[pos] = {color = color, timer = 30, def = def}
|
||||
|
||||
local timer = 0
|
||||
end
|
||||
|
||||
|
||||
local lingering_timer = 0
|
||||
minetest.register_globalstep(function(dtime)
|
||||
|
||||
timer = timer + dtime
|
||||
|
||||
if timer >= 1 then
|
||||
lingering_timer = lingering_timer + dtime
|
||||
if lingering_timer >= 1 then
|
||||
|
||||
for pos, vals in pairs(lingering_effect_at) do
|
||||
|
||||
if lingering_effect_at[pos] then
|
||||
|
||||
lingering_effect_at[pos].timer = lingering_effect_at[pos].timer - timer
|
||||
|
||||
-- print(lingering_effect_at[pos].timer)
|
||||
|
||||
if lingering_effect_at[pos].timer > 0 then
|
||||
|
||||
local d = 4 * (lingering_effect_at[pos].timer / 30.0)
|
||||
vals.timer = vals.timer - lingering_timer
|
||||
local d = 4 * (vals.timer / 30.0)
|
||||
|
||||
minetest.add_particlespawner({
|
||||
amount = 5 * d^2,
|
||||
|
@ -47,7 +41,7 @@ local function add_lingering_effect(pos, color, def)
|
|||
maxsize = 4,
|
||||
collisiondetection = true,
|
||||
vertical = false,
|
||||
texture = "mcl_potions_sprite.png^[colorize:"..lingering_effect_at[pos].color..":127",
|
||||
texture = "mcl_potions_sprite.png^[colorize:"..vals.color..":127",
|
||||
})
|
||||
|
||||
for _, obj in pairs(minetest.get_objects_inside_radius(pos, d)) do
|
||||
|
@ -55,26 +49,19 @@ local function add_lingering_effect(pos, color, def)
|
|||
local entity = obj:get_luaentity()
|
||||
if obj:is_player() or entity._cmi_is_mob then
|
||||
|
||||
-- if obj:is_player() then print(obj:is_player()) print(obj:get_player_name()) end
|
||||
-- if entity then print(entity.name) print(entity._cmi_is_mob) end
|
||||
|
||||
lingering_effect_at[pos].def.potion_fun(obj)
|
||||
lingering_effect_at[pos].timer = lingering_effect_at[pos].timer / 2
|
||||
vals.def.potion_fun(obj)
|
||||
vals.timer = vals.timer / 2
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
lingering_effect_at[pos] = nil
|
||||
if vals.timer <= 0 then lingering_effect_at[pos] = nil end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
timer = 0
|
||||
lingering_timer = 0
|
||||
end
|
||||
end)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function register_lingering(name, descr, color, def)
|
||||
|
@ -114,7 +101,7 @@ local function register_lingering(name, descr, color, def)
|
|||
minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1})
|
||||
add_lingering_effect(pos, color, def)
|
||||
minetest.add_particlespawner({
|
||||
amount = 20,
|
||||
amount = 40,
|
||||
time = 1,
|
||||
minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d},
|
||||
maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d},
|
||||
|
|
Loading…
Reference in New Issue