Heart particles while cats are purring

This commit is contained in:
Aaron Suen 2023-05-19 20:11:15 -04:00
parent 89dfd5313a
commit cd5ea51967
2 changed files with 30 additions and 2 deletions

32
pet.lua
View File

@ -1,8 +1,8 @@
-- LUALOCALS < ---------------------------------------------------------
local math, minetest, nodecore, pairs, vector
= math, minetest, nodecore, pairs, vector
local math_abs, math_random
= math.abs, math.random
local math_abs, math_floor, math_random
= math.abs, math.floor, math.random
-- LUALOCALS > ---------------------------------------------------------
local modname = minetest.get_current_modname()
@ -54,6 +54,32 @@ local function playernear(pos)
end
end
local function hearticles(pos, offs, time, qty)
minetest.add_particlespawner({
amount = math_floor(2 * qty),
time = time,
minpos = vector.add(pos, offs),
maxpos = vector.subtract(pos, offs),
texture = "nc_cats_heart.png",
minexptime = 1,
maxexptime = 2,
minsize = 1,
maxsize = 2,
glow = 4
})
end
local function hearticles_all(pos, time, qty)
local pdist = 0.55
for _, d in pairs({
{p = {x = pdist, y = 0, z = 0}, o = {x = 0, y = pdist, z = pdist}},
{p = {x = 0, y = pdist, z = 0}, o = {x = pdist, y = 0, z = pdist}},
{p = {x = 0, y = 0, z = pdist}, o = {x = pdist, y = pdist, z = 0}},
}) do
hearticles(vector.add(pos, d.p), d.o, time, qty)
hearticles(vector.subtract(pos, d.p), d.o, time, qty)
end
end
local function purr(pos, data)
purring[hashpos(pos)] = nodecore.gametime
@ -65,6 +91,7 @@ local function purr(pos, data)
gain = purrgain,
not_ephemeral = fade
})
hearticles_all(pos, purrtimes[id], purrtimes[id])
if fade then
minetest.sound_fade(sh, -purrgain / purrtimes[id], 0)
return minetest.after(purrtimes[id], function()
@ -104,6 +131,7 @@ local function furballcheck(pos, node, ejectpos)
end
local function purrstart(pos, data)
furballcheck(pos)
hearticles_all(pos, 0.05, 1)
return purr(pos, data)
end

BIN
textures/nc_cats_heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B