make townaura more preformant

This commit is contained in:
epCode 2022-11-13 14:22:00 -08:00 committed by cora
parent 28f952309e
commit c288b6ab93

View File

@ -448,28 +448,40 @@ minetest.register_node("mcl_core:mycelium", {
}) })
mcl_core.register_snowed_node("mcl_core:mycelium_snow", "mcl_core:mycelium", nil, nil, false, S("Mycelium with Snow")) mcl_core.register_snowed_node("mcl_core:mycelium_snow", "mcl_core:mycelium", nil, nil, false, S("Mycelium with Snow"))
local PARTICLE_ABM_DISTANCE = 16
--if minetest.settings:get("mcl_node_particles") == "full" then --if minetest.settings:get("mcl_node_particles") == "full" then
minetest.register_abm({ minetest.register_abm({
label = "Townaura particles", label = "Townaura particles",
nodenames = {"group:mycelium"}, nodenames = {"group:mycelium"},
interval = 0.1, interval = 2,
chance = 30, chance = 30,
action = function(pos, node) action = function(pos, node)
local apos = {x=pos.x, y=pos.y+0.51, z=pos.z} local player_near = false
local vel = { x = math.random(-3, 3)/10, y = math.random(0, 10)/60, z = math.random(-3, 3)/10 } for _,player in pairs(minetest.get_connected_players()) do
if vector.distance(player:get_pos(), pos) < PARTICLE_ABM_DISTANCE then
player_near = true
end
end
if player_near then
local apos = {x=pos.x-2, y=pos.y+0.51, z=pos.z-2}
local apos2 = {x=pos.x+2, y=pos.y+0.51, z=pos.z+2}
local acc = { x = 0, y = 0, z = 0 } local acc = { x = 0, y = 0, z = 0 }
minetest.add_particle({ minetest.add_particlespawner({
pos = apos, time = 2,
velocity = vel, amount = 5,
acceleration = acc, minpos = apos,
maxpos = apos2,
minvel = vector.new(-3/10, 0, -3/10),
maxvel = vector.new(3/10, 10/60, 3/10),
minacc = acc,
expirationtime = 4, expirationtime = 4,
collisiondetection = true, collisiondetection = true,
collision_removal = true, collision_removal = true,
size = 1, size = 1,
texture = "mcl_core_mycelium_particle.png", texture = "mcl_core_mycelium_particle.png",
glow = LIGHT_LAVA,
}) })
end
end, end,
}) })
--end --end