mcl_explosions_fixes

- use new vectors
- remove deprecated use of vector.new()
- add some type annotations
This commit is contained in:
AFCMS 2022-10-15 15:32:03 +02:00 committed by cora
parent 0a68562301
commit 8da8040324

View file

@ -130,10 +130,10 @@ local function add_particles(pos, radius)
time = 0.125, time = 0.125,
minpos = pos, minpos = pos,
maxpos = pos, maxpos = pos,
minvel = {x = -radius, y = -radius, z = -radius}, minvel = vector.new(-radius, -radius, -radius),
maxvel = {x = radius, y = radius, z = radius}, maxvel = vector.new(radius, radius, radius),
minacc = vector.new(), minacc = vector.zero(),
maxacc = vector.new(), maxacc = vector.zero(),
minexptime = 0.5, minexptime = 0.5,
maxexptime = 1.0, maxexptime = 1.0,
minsize = radius * 0.5, minsize = radius * 0.5,
@ -333,7 +333,8 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
end end
if sleep_formspec_doesnt_close_mt53 then if sleep_formspec_doesnt_close_mt53 then
minetest.after(0.3, function() -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE minetest.after(0.3,
function() -- 0.2 is minimum delay for closing old formspec and open died formspec -- TODO: REMOVE THIS IN THE FUTURE
if not obj:is_player() then if not obj:is_player() then
return return
end end
@ -396,15 +397,16 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
-- Update falling nodes -- Update falling nodes
for a = 1, #airs do for a = 1, #airs do
local p = airs[a] local p = airs[a]
check_for_falling({x=p.x, y=p.y+1, z=p.z}) check_for_falling(vector.offset(p, 0, 1, 0))
end end
for f = 1, #fires do for f = 1, #fires do
local p = fires[f] local p = fires[f]
check_for_falling({x=p.x, y=p.y+1, z=p.z}) check_for_falling(vector.offset(p, 0, 1, 0))
end end
-- Log explosion -- Log explosion
minetest.log("action", "Explosion at "..pos_to_string(pos).." with strength "..strength.." and radius "..radius) minetest.log("action", "Explosion at " .. pos_to_string(pos) .. " with strength " .. strength .. " and radius " ..
radius)
end end
-- Create an explosion with strength at pos. -- Create an explosion with strength at pos.
@ -428,6 +430,11 @@ end
-- griefing - If true, the explosion will destroy nodes (default: true) -- griefing - If true, the explosion will destroy nodes (default: true)
-- grief_protected - If true, the explosion will also destroy nodes which have -- grief_protected - If true, the explosion will also destroy nodes which have
-- been protected (default: false) -- been protected (default: false)
---@param pos Vector
---@param strength number
---@param info {drop_chance: number, max_blast_resistance: number, sound: boolean, particles: boolean, fire: boolean, griefing: boolean, grief_protected: boolean}
---@param direct? ObjectRef
---@param source? ObjectRef
function mcl_explosions.explode(pos, strength, info, direct, source) function mcl_explosions.explode(pos, strength, info, direct, source)
if info == nil then if info == nil then
info = {} info = {}