Make glyph particles more close to MC and visible only for players in radius 15
This commit is contained in:
parent
dc5ff37449
commit
c2a14e2eae
|
@ -295,23 +295,41 @@ minetest.register_abm({
|
||||||
chance = 1,
|
chance = 1,
|
||||||
nodenames = "mcl_enchanting:table",
|
nodenames = "mcl_enchanting:table",
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
|
local playernames = {}
|
||||||
|
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 15)) do
|
||||||
|
if obj:is_player() then
|
||||||
|
table.insert(playernames, obj:get_player_name())
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if #playernames < 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
local absolute, relative = mcl_enchanting.get_bookshelves(pos)
|
local absolute, relative = mcl_enchanting.get_bookshelves(pos)
|
||||||
for i, ap in ipairs(absolute) do
|
for i, ap in ipairs(absolute) do
|
||||||
if math.random(10) == 1 then
|
if math.random(5) == 1 then
|
||||||
local rp = relative[i]
|
local rp = relative[i]
|
||||||
|
local t = math.random()+1 --time
|
||||||
|
local d = {x = rp.x, y=rp.y-0.7, z=rp.z} --distance
|
||||||
|
local v = {x = -math.random()*d.x, y = math.random(), z = -math.random()*d.z} --velocity
|
||||||
|
local a = {x = 2*(-v.x*t - d.x)/t/t, y = 2*(-v.y*t - d.y)/t/t, z = 2*(-v.z*t - d.z)/t/t} --acceleration
|
||||||
|
local s = math.random()+0.9 --size
|
||||||
|
t = t - 0.1 --slightly decrease time to avoid texture overlappings
|
||||||
|
local tx = "mcl_enchanting_glyph_" .. math.random(18) .. ".png"
|
||||||
|
for _, name in pairs(playernames) do
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = ap,
|
pos = ap,
|
||||||
velocity = vector.subtract(vector.new(0, 5, 0), rp),
|
velocity = v,
|
||||||
acceleration = {x = 0, y = -9.81, z = 0},
|
acceleration = a,
|
||||||
expirationtime = 2,
|
expirationtime = t,
|
||||||
size = 2,
|
size = s,
|
||||||
texture = "mcl_enchanting_glyph_" .. math.random(18) .. ".png",
|
texture = tx,
|
||||||
collision_detection = true,
|
collisiondetection = false,
|
||||||
collision_removal = true,
|
playername = name
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_lbm({
|
minetest.register_lbm({
|
||||||
|
|
Loading…
Reference in New Issue