mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-09 17:30:21 +01:00
add mob_class:go_to(pos) function
This commit is contained in:
parent
be2d630fdf
commit
1536b9a5fc
29
api.lua
29
api.lua
@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators")
|
|||||||
-- Global
|
-- Global
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20240505",
|
version = "20240524",
|
||||||
translate = S,
|
translate = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {},
|
invis = minetest.global_exists("invisibility") and invisibility or {},
|
||||||
node_snow = minetest.registered_aliases["mapgen_snow"]
|
node_snow = minetest.registered_aliases["mapgen_snow"]
|
||||||
@ -1866,6 +1866,33 @@ function mob_class:smart_mobs(s, p, dist, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- temp entity for go_to() function
|
||||||
|
minetest.register_entity("mobs:_pos", {
|
||||||
|
initial_properties = {
|
||||||
|
visual = "sprite", texture = "", hp_max = 1, physical = false,
|
||||||
|
static_save = false, pointable = false, is_visible = false
|
||||||
|
}, health = 1, _cmi_is_mob = true,
|
||||||
|
on_step = function(self, dtime)
|
||||||
|
|
||||||
|
self.counter = (self.counter or 0) + dtime
|
||||||
|
|
||||||
|
if self.counter > 10 then
|
||||||
|
self.object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
-- add temp entity and make mob go to that entity position
|
||||||
|
function mob_class:go_to(pos)
|
||||||
|
|
||||||
|
local obj = minetest.add_entity(pos, "mobs:_pos")
|
||||||
|
|
||||||
|
if obj and obj:get_luaentity() then
|
||||||
|
self:do_attack(obj)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- peaceful player privilege support
|
-- peaceful player privilege support
|
||||||
local function is_peaceful_player(player)
|
local function is_peaceful_player(player)
|
||||||
|
|
||||||
|
4
api.txt
4
api.txt
@ -419,7 +419,9 @@ mob_class:day_docile() -- return True if mob docile during current daytime
|
|||||||
mob_class:mob_expire(pos, dtime) -- check if mob is to despawn
|
mob_class:mob_expire(pos, dtime) -- check if mob is to despawn
|
||||||
mob_class:get_nodes() -- get specific nodes around mob
|
mob_class:get_nodes() -- get specific nodes around mob
|
||||||
mob_class:on_blast(damage) -- function called when mob in blast area
|
mob_class:on_blast(damage) -- function called when mob in blast area
|
||||||
mob_class:is_inside(itemtable) -- returns True is mob collisionbox inside any node/group in table
|
mob_class:is_inside(itemtable) -- returns True is mob collisionbox inside any node/group
|
||||||
|
in table
|
||||||
|
mob_class:go_to(pos) -- makes mob go to that position or nearby
|
||||||
|
|
||||||
|
|
||||||
Adding Mobs in World
|
Adding Mobs in World
|
||||||
|
Loading…
Reference in New Issue
Block a user