capturetheflag/mods/pvp/grenades/api.md

33 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2020-05-05 17:30:47 +00:00
# Grenades API
2020-05-14 17:03:06 +00:00
Please suggest new features here: https://forum.minetest.net/viewtopic.php?f=9&t=21466
2020-05-05 17:30:47 +00:00
## API
2020-05-14 17:03:06 +00:00
```lua
grenades.register_grenade("name", { -- Name of the grenade (Like 'smoke' or 'flashbang')
description = "", -- A short description of the grenade.
image = "", -- The name of the grenade's texture
on_explode = function(pos, name)
-- This function is called when the grenade 'explodes'
-- <pos> the place the grenade 'exploded' at
-- <name> the name of the player that threw the grenade
end,
on_collide = function(obj, name)
-- This function is called when the grenade collides with a surface
-- <obj> the grenade object
-- <name> the name of the player that threw the grenade
-- return true to cause grenade explosion
-- return "stop" to stop the grenade from moving
2020-05-14 17:03:06 +00:00
end,
clock = 3, -- Optional, controls how long until grenade detonates. Default is 3
particle = { -- Adds particles in the grenade's trail
image = "grenades_smoke.png", -- The particle's image
life = 1, -- How long (seconds) it takes for the particle to disappear
size = 4, -- Size of the particle
glow = 0, -- Brightens the texture in darkness
interval = 5, -- How long it takes before a particle can be added
}
})
```