mirror of
https://github.com/LoneWolfHT/grenades.git
synced 2024-11-22 06:43:45 +01:00
Added trailing smoke particles to the smoke grenade when thrown
This commit is contained in:
parent
f8c09f12de
commit
44200386f9
5
API.md
5
API.md
@ -18,6 +18,7 @@ Still WIP. Please suggest new features here: https://forum.minetest.net/viewtopi
|
|||||||
image = "grenades_smoke.png", -- The particle's image
|
image = "grenades_smoke.png", -- The particle's image
|
||||||
life = 1, -- How long (seconds) it takes for the particle to disappear
|
life = 1, -- How long (seconds) it takes for the particle to disappear
|
||||||
size = 4, -- Size of the particle
|
size = 4, -- Size of the particle
|
||||||
glow = 0, -- brightens the texture in darkness
|
glow = 0, -- Brightens the texture in darkness
|
||||||
|
interval = 5, -- How long it takes before a particle can be added
|
||||||
}
|
}
|
||||||
})`
|
})`
|
||||||
|
1
depends.txt
Normal file
1
depends.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
default
|
@ -116,6 +116,7 @@ if not smoke or smoke == true then
|
|||||||
life = 1,
|
life = 1,
|
||||||
size = 4,
|
size = 4,
|
||||||
glow = 0,
|
glow = 0,
|
||||||
|
interval = 5,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -130,7 +131,7 @@ if not settings:get_bool("enable_grenade_recipes") or settings:get_bool("enable_
|
|||||||
|
|
||||||
if not regular or regular == true then
|
if not regular or regular == true then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shaped",
|
||||||
output = "grenades:grenade_regular",
|
output = "grenades:grenade_regular",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:steel_ingot", ""},
|
{"", "default:steel_ingot", ""},
|
||||||
@ -144,7 +145,7 @@ if not settings:get_bool("enable_grenade_recipes") or settings:get_bool("enable_
|
|||||||
|
|
||||||
if not smoke or smoke == true then
|
if not smoke or smoke == true then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shaped",
|
||||||
output = "grenades:grenade_smoke",
|
output = "grenades:grenade_smoke",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:steel_ingot", ""},
|
{"", "default:steel_ingot", ""},
|
||||||
@ -158,7 +159,7 @@ if not settings:get_bool("enable_grenade_recipes") or settings:get_bool("enable_
|
|||||||
|
|
||||||
if not flash or flash == true then
|
if not flash or flash == true then
|
||||||
minetest.register_craft({
|
minetest.register_craft({
|
||||||
type = "shapeless",
|
type = "shaped",
|
||||||
output = "grenades:grenade_flashbang",
|
output = "grenades:grenade_flashbang",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "default:steel_ingot", ""},
|
{"", "default:steel_ingot", ""},
|
||||||
|
10
init.lua
10
init.lua
@ -28,13 +28,19 @@ function grenades.register_grenade(name, def)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local obj = self.object
|
local obj = self.object
|
||||||
|
|
||||||
|
if self.particle == nil then
|
||||||
|
self.particle = 0
|
||||||
|
end
|
||||||
|
|
||||||
if self.timer then
|
if self.timer then
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
else
|
else
|
||||||
self.timer = dtime
|
self.timer = dtime
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.particle then
|
if def.particle and self.particle >= 4 then
|
||||||
|
self.particle = 0
|
||||||
|
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = obj:get_pos(),
|
pos = obj:get_pos(),
|
||||||
velocity = vector.divide(obj:get_velocity(), 2),
|
velocity = vector.divide(obj:get_velocity(), 2),
|
||||||
@ -47,6 +53,8 @@ function grenades.register_grenade(name, def)
|
|||||||
texture = def.particle.image,
|
texture = def.particle.image,
|
||||||
glow = def.particle.glow
|
glow = def.particle.glow
|
||||||
})
|
})
|
||||||
|
elseif def.particle and self.particle < def.particle.interval then
|
||||||
|
self.particle = self.particle + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.timer > def.timeout or node.name ~= "air" then
|
if self.timer > def.timeout or node.name ~= "air" then
|
||||||
|
Loading…
Reference in New Issue
Block a user