Settings of Particles

This commit is contained in:
Lunovox 2022-05-18 00:33:01 -03:00
parent 6b1c770403
commit 91a65007ac
2 changed files with 41 additions and 28 deletions

@ -1,3 +1,7 @@
void_chest = {
show_particles = (minetest.settings:get("void_chest.show_particles") ~= "false")
}
-- Register the void chest.
minetest.register_node("void_chest:void_chest", {
description = "" ..core.colorize("#660099","Void Chest\n") ..core.colorize("#FFFFFF", "Use the power of the void to store your items."),
@ -8,8 +12,10 @@ minetest.register_node("void_chest:void_chest", {
legacy_facedir_simple = true,
sounds = default.node_sound_wood_defaults(),
on_construct = function(pos)
local timer = minetest.get_node_timer(pos)
timer:start(.1) -- in seconds
if void_chest.show_particles then
local timer = minetest.get_node_timer(pos)
timer:start(.1) -- in seconds
end
local meta = minetest.get_meta(pos)
meta:set_string("formspec",
"size[8,9]"..
@ -38,32 +44,32 @@ minetest.register_node("void_chest:void_chest", {
" takes stuff from void chest at "..minetest.pos_to_string(pos))
end,
on_timer = function(pos)
-- Particles for the void effect, implemented by MisterE, thanks!
for i=1,10 do -- number of particles spawned every on_timer
local vel_scalar = math.random(0,5)/10 -- multiplied by the particle's velocity vector of 1
local accel_scalar = math.random(1,5)/10 -- multiplied by the particle's accel vector of 1
local expir = math.random(1,10) -- number of sec particle will last, if it doesn't hit a node
local particle_pos = {x=pos.x + ((math.random(-10,10)/10)*(math.random(6,15)/10)), y=pos.y + ((math.random(-10,10)/10)*(math.random(6,15)/10)), z=pos.z+ ((math.random(-10,10)/10)*(math.random(6,15)/10))}
local part_vel = vector.direction(particle_pos, pos)
part_vel = {x= vel_scalar*part_vel.x, y= vel_scalar*part_vel.y, z= vel_scalar*part_vel.z}
local part_accel = vector.direction(particle_pos, pos)
part_accel = {x= accel_scalar*part_accel.x, y= accel_scalar*part_accel.y, z= accel_scalar*part_accel.z}
minetest.add_particle({
pos = particle_pos,
velocity = part_vel,
acceleration = part_accel,
expirationtime = expir,
size = math.random(7,10)/10,
collisiondetection = true,
collision_removal = true,
vertical = false,
texture = "void_chest_void_particle.png",
glow = 5,
})
if void_chest.show_particles then
-- Particles for the void effect, implemented by MisterE, thanks!
for i=1,10 do -- number of particles spawned every on_timer
local vel_scalar = math.random(0,5)/10 -- multiplied by the particle's velocity vector of 1
local accel_scalar = math.random(1,5)/10 -- multiplied by the particle's accel vector of 1
local expir = math.random(1,10) -- number of sec particle will last, if it doesn't hit a node
local particle_pos = {x=pos.x + ((math.random(-10,10)/10)*(math.random(6,15)/10)), y=pos.y + ((math.random(-10,10)/10)*(math.random(6,15)/10)), z=pos.z+ ((math.random(-10,10)/10)*(math.random(6,15)/10))}
local part_vel = vector.direction(particle_pos, pos)
part_vel = {x= vel_scalar*part_vel.x, y= vel_scalar*part_vel.y, z= vel_scalar*part_vel.z}
local part_accel = vector.direction(particle_pos, pos)
part_accel = {x= accel_scalar*part_accel.x, y= accel_scalar*part_accel.y, z= accel_scalar*part_accel.z}
minetest.add_particle({
pos = particle_pos,
velocity = part_vel,
acceleration = part_accel,
expirationtime = expir,
size = math.random(7,10)/10,
collisiondetection = true,
collision_removal = true,
vertical = false,
texture = "void_chest_void_particle.png",
glow = 5,
})
end
end
return true
return true
end,
})
@ -80,7 +86,7 @@ if minetest.get_modpath("magic_materials") then
}
})
else -- Else we use a recipe using "default" to avoid a hard dependency.
minetest.register_craft({
minetest.register_craft({
output = 'void_chest:void_chest',
recipe = {
{'default:steelblock','default:obsidian_block','default:steelblock'},

7
settingtypes.txt Normal file

@ -0,0 +1,7 @@
# VOID CHEST SETTINGS
# VOID CHEST:
# on low performance servers the particles can cause a drop in performance.
# Default: true
void_chest.show_particles (Show Particles) bool true