diff --git a/api.lua b/api.lua index b26011d..4a10073 100644 --- a/api.lua +++ b/api.lua @@ -14,7 +14,7 @@ local use_vh1 = minetest.get_modpath("visual_harm_1ndicators") -- Global mobs = { mod = "redo", - version = "20240505", + version = "20240524", translate = S, invis = minetest.global_exists("invisibility") and invisibility or {}, node_snow = minetest.registered_aliases["mapgen_snow"] @@ -1866,6 +1866,33 @@ function mob_class:smart_mobs(s, p, dist, dtime) 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 local function is_peaceful_player(player) diff --git a/api.txt b/api.txt index 895805e..6f5972a 100644 --- a/api.txt +++ b/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:get_nodes() -- get specific nodes around mob 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