mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 18:30:21 +01:00
add mobs:mob_reset_stick
This commit is contained in:
parent
8da3bb5cb1
commit
a1d4e9bbfc
2
api.lua
2
api.lua
@ -2963,7 +2963,7 @@ function mob_class:mob_activate(staticdata, def, dtime)
|
||||
end
|
||||
|
||||
if self.health == 0 then
|
||||
self.health = random (self.hp_min, self.hp_max)
|
||||
self.health = random(self.hp_min, self.hp_max)
|
||||
end
|
||||
|
||||
-- pathfinding init
|
||||
|
48
crafts.lua
48
crafts.lua
@ -219,3 +219,51 @@ minetest.register_craft({
|
||||
recipe = "mobs:fence_top",
|
||||
burntime = 2,
|
||||
})
|
||||
|
||||
-- this tool spawns same mob and adds owner, protected, nametag info
|
||||
-- then removes original entity, this is used for fixing any issues.
|
||||
|
||||
minetest.register_tool(":mobs:mob_reset_stick", {
|
||||
description = "Mob Reset Stick",
|
||||
inventory_image = "default_stick.png^[colorize:#ff000050",
|
||||
stack_max = 1,
|
||||
groups = {not_in_creative_inventory = 1},
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
local privs = minetest.get_player_privs(user:get_player_name())
|
||||
|
||||
if pointed_thing.type ~= "object" then
|
||||
return
|
||||
end
|
||||
|
||||
local obj = pointed_thing.ref
|
||||
|
||||
if obj then
|
||||
|
||||
local self = obj:get_luaentity()
|
||||
local obj2 = minetest.add_entity(obj:get_pos(), self.name)
|
||||
|
||||
if obj2 then
|
||||
|
||||
local ent2 = obj2:get_luaentity()
|
||||
|
||||
ent2.protected = self.protected
|
||||
ent2.owner = self.owner
|
||||
ent2.nametag = self.nametag
|
||||
ent2.gotten = self.gotten
|
||||
ent2.tamed = self.tamed
|
||||
ent2.health = self.health
|
||||
|
||||
if self.child then
|
||||
obj2:set_velocity({x = 0, y = self.jump_height, z = 0})
|
||||
end
|
||||
|
||||
obj2:set_properties({nametag = self.nametag})
|
||||
|
||||
obj:remove()
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user