Initial commit
This commit is contained in:
commit
5e8ff01ab7
3 changed files with 51 additions and 0 deletions
49
init.lua
Normal file
49
init.lua
Normal file
|
@ -0,0 +1,49 @@
|
|||
function show_heart(pos)
|
||||
minetest.add_particle(
|
||||
{
|
||||
pos = pos,
|
||||
velocity = {x=0, y=1, z=0},
|
||||
acceleration = {x=0, y=0, z=0},
|
||||
-- Spawn particle at pos with velocity and acceleration
|
||||
|
||||
expirationtime = 1,
|
||||
-- Disappears after expirationtime seconds
|
||||
|
||||
size = 3,
|
||||
-- Scales the visual size of the particle texture.
|
||||
-- If `node` is set, size can be set to 0 to spawn a randomly-sized
|
||||
-- particle (just like actual node dig particles).
|
||||
|
||||
texture = "heart.png",
|
||||
-- The texture of the particle
|
||||
|
||||
glow = 0
|
||||
-- Optional, specify particle self-luminescence in darkness.
|
||||
-- Values 0-14.
|
||||
}
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
function show_hearts(player)
|
||||
local hearts = 2+math.ceil(math.random()*3)
|
||||
local player_pos = player:get_pos()
|
||||
local looking_dir = player:get_look_dir()
|
||||
looking_dir.y = 0
|
||||
|
||||
for i=0,hearts do
|
||||
local vert_offset = 1.5*math.random()-0.75
|
||||
local y_offset = 0.5*math.random() + 1.5
|
||||
local offset = vector.multiply(looking_dir, vert_offset)
|
||||
offset.y = y_offset
|
||||
offset.x, offset.z = offset.z, offset.x
|
||||
|
||||
show_heart(vector.add(player_pos,offset))
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_on_player_hpchange(function(player, hp_change, reason)
|
||||
if hp_change < 0 then
|
||||
show_hearts(player)
|
||||
end
|
||||
end)
|
2
mod.conf
Normal file
2
mod.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
name=testochism
|
||||
description="A small mod to show heart particles when taking damage"
|
BIN
textures/heart.png
Normal file
BIN
textures/heart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 61 KiB |
Loading…
Reference in a new issue