add particle effect global function, arrow lifetime, api.txt update
This commit is contained in:
parent
245128f9e6
commit
ec122aa6de
22
api.lua
22
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200619",
|
version = "20200620",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -645,7 +645,14 @@ local effect = function(pos, amount, texture, min_size, max_size,
|
|||||||
max_size = max_size or 1
|
max_size = max_size or 1
|
||||||
gravity = gravity or -10
|
gravity = gravity or -10
|
||||||
glow = glow or 0
|
glow = glow or 0
|
||||||
fall = fall and 0 or -radius
|
|
||||||
|
if fall == true then
|
||||||
|
fall = 0
|
||||||
|
elseif fall == false then
|
||||||
|
fall = radius
|
||||||
|
else
|
||||||
|
fall = -radius
|
||||||
|
end
|
||||||
|
|
||||||
minetest.add_particlespawner({
|
minetest.add_particlespawner({
|
||||||
amount = amount,
|
amount = amount,
|
||||||
@ -665,6 +672,12 @@ local effect = function(pos, amount, texture, min_size, max_size,
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mobs:effect(pos, amount, texture, min_size, max_size,
|
||||||
|
radius, gravity, glow, fall)
|
||||||
|
|
||||||
|
effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, fall)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- update nametag colour
|
-- update nametag colour
|
||||||
function mob_class:update_tag()
|
function mob_class:update_tag()
|
||||||
@ -3862,6 +3875,7 @@ function mobs:register_arrow(name, def)
|
|||||||
drop = def.drop or false, -- drops arrow as registered item when true
|
drop = def.drop or false, -- drops arrow as registered item when true
|
||||||
collisionbox = def.collisionbox or {-.1, -.1, -.1, .1, .1, .1},
|
collisionbox = def.collisionbox or {-.1, -.1, -.1, .1, .1, .1},
|
||||||
timer = 0,
|
timer = 0,
|
||||||
|
lifetime = def.lifetime or 4.5,
|
||||||
switch = 0,
|
switch = 0,
|
||||||
owner_id = def.owner_id,
|
owner_id = def.owner_id,
|
||||||
rotate = def.rotate,
|
rotate = def.rotate,
|
||||||
@ -3876,11 +3890,11 @@ function mobs:register_arrow(name, def)
|
|||||||
|
|
||||||
on_step = def.on_step or function(self, dtime)
|
on_step = def.on_step or function(self, dtime)
|
||||||
|
|
||||||
self.timer = self.timer + 1
|
self.timer = self.timer + dtime
|
||||||
|
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
|
|
||||||
if self.switch == 0 or self.timer > 150 then
|
if self.switch == 0 or self.timer > self.lifetime then
|
||||||
|
|
||||||
self.object:remove() ; -- print("removed arrow")
|
self.object:remove() ; -- print("removed arrow")
|
||||||
|
|
||||||
|
25
api.txt
25
api.txt
@ -293,7 +293,8 @@ enhance mob functionality and have them do many interesting things:
|
|||||||
'custom_attack' when set this function is called instead of the normal mob
|
'custom_attack' when set this function is called instead of the normal mob
|
||||||
melee attack, parameters are (self, to_attack) and if true
|
melee attack, parameters are (self, to_attack) and if true
|
||||||
is returned normal attack function continued.
|
is returned normal attack function continued.
|
||||||
'on_die' a function that is called when mob is killed (self, pos)
|
'on_die' a function that is called when mob is killed (self, pos), also
|
||||||
|
has access to self.cause_of_death table.
|
||||||
'do_custom' a custom function that is called every tick while mob is
|
'do_custom' a custom function that is called every tick while mob is
|
||||||
active and which has access to all of the self.* variables
|
active and which has access to all of the self.* variables
|
||||||
e.g. (self.health for health or self.standing_in for node
|
e.g. (self.health for health or self.standing_in for node
|
||||||
@ -387,6 +388,24 @@ true the mob will not spawn.
|
|||||||
'name' is the name of the animal/monster
|
'name' is the name of the animal/monster
|
||||||
|
|
||||||
|
|
||||||
|
Particle Effects
|
||||||
|
----------------
|
||||||
|
|
||||||
|
mobs:effect(pos, amount, texture, min_size, max_size, radius, gravity, glow, fall)
|
||||||
|
|
||||||
|
This function provides a quick way to spawn particles as an effect.
|
||||||
|
|
||||||
|
'pos' center position of particle effect.
|
||||||
|
'amount' how many particles.
|
||||||
|
'texture' texture filename to use for effect.
|
||||||
|
'min_size' smallest particle size.
|
||||||
|
'max_size' largest particle size.
|
||||||
|
'radius' how far particles spread outward from center.
|
||||||
|
'gravity' gravity applied to particles once they spawn.
|
||||||
|
'glow' number between 1 and 15 for glowing particles.
|
||||||
|
'fall' when true particles fall, false has them rising, nil has them scatter.
|
||||||
|
|
||||||
|
|
||||||
Making Arrows
|
Making Arrows
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
@ -422,7 +441,9 @@ This function registers a arrow for mobs with the attack type shoot.
|
|||||||
'on_step' is a custom function when arrow is active, nil for
|
'on_step' is a custom function when arrow is active, nil for
|
||||||
default.
|
default.
|
||||||
'on_punch' is a custom function when arrow is punched, nil by default
|
'on_punch' is a custom function when arrow is punched, nil by default
|
||||||
'collisionbox' is hitbox table for arrow, {0,0,0,0,0,0} by default.
|
'collisionbox' is hitbox table for arrow, {-.1,-.1,-.1,.1,.1,.1} by default.
|
||||||
|
'lifetime' contains float value for how many seconds arrow exists in
|
||||||
|
world before being removed (default is 4.5 seconds).
|
||||||
|
|
||||||
|
|
||||||
Spawn Eggs
|
Spawn Eggs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user