From 5e6e4967f0fdeca5e771ba412d6a320497f576b7 Mon Sep 17 00:00:00 2001 From: kno10 Date: Fri, 16 Aug 2024 22:01:19 +0200 Subject: [PATCH] Fix crying obsidian particles (#4583) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LUAs `math.random(a,b)` expects a and b to be integers. `size` was only randomized once. Reviewed-on: https://git.minetest.land/VoxeLibre/VoxeLibre/pulls/4583 Reviewed-by: Mikita Wiśniewski Co-authored-by: kno10 Co-committed-by: kno10 --- mods/ITEMS/mcl_core/functions.lua | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index b520777d6..64d3e2197 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -1658,32 +1658,30 @@ end -- Obsidian crying - local crobby_particle = { - velocity = vector.new(0,0,0), - size = math.random(1.3,2.5), + velocity = vector.zero(), + acceleration = vector.zero(), texture = "mcl_core_crying_obsidian_tear.png", + collisiondetection = false, collision_removal = false, } - minetest.register_abm({ label = "Obsidian cries", nodenames = {"mcl_core:crying_obsidian"}, interval = 5, chance = 10, action = function(pos, node) - minetest.after(math.random(0.1,1.5),function() + minetest.after(0.1 + math.random() * 1.4, function() local pt = table.copy(crobby_particle) - pt.acceleration = vector.new(0,0,0) - pt.collisiondetection = false - pt.expirationtime = math.random(0.5,1.5) - pt.pos = vector.offset(pos,math.random(-0.5,0.5),-0.51,math.random(-0.5,0.5)) + pt.size = 1.3 + math.random() * 1.2 + pt.expirationtime = 0.5 + math.random() + pt.pos = vector.offset(pos, math.random() - 0.5, -0.51, math.random() - 0.5) minetest.add_particle(pt) - minetest.after(pt.expirationtime,function() - pt.acceleration = vector.new(0,-9,0) + minetest.after(pt.expirationtime, function() + pt.acceleration = vector.new(0, -9, 0) pt.collisiondetection = true - pt.expirationtime = math.random(1.2,4.5) + pt.expirationtime = 1.2 + math.random() * 3.3 minetest.add_particle(pt) end) end)