mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2025-01-11 18:30:21 +01:00
on_replace returns node names, even when groups used
This commit is contained in:
parent
5958270158
commit
c5b74230e5
21
api.lua
21
api.lua
@ -6,7 +6,7 @@ local use_cmi = minetest.global_exists("cmi")
|
|||||||
|
|
||||||
mobs = {
|
mobs = {
|
||||||
mod = "redo",
|
mod = "redo",
|
||||||
version = "20200109",
|
version = "20200112",
|
||||||
intllib = S,
|
intllib = S,
|
||||||
invis = minetest.global_exists("invisibility") and invisibility or {}
|
invis = minetest.global_exists("invisibility") and invisibility or {}
|
||||||
}
|
}
|
||||||
@ -1338,18 +1338,23 @@ function mob_class:replace(pos)
|
|||||||
|
|
||||||
-- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
|
-- print ("replace node = ".. minetest.get_node(pos).name, pos.y)
|
||||||
|
|
||||||
local oldnode = {name = what}
|
|
||||||
local newnode = {name = with}
|
|
||||||
local on_replace_return
|
|
||||||
|
|
||||||
if self.on_replace then
|
if self.on_replace then
|
||||||
on_replace_return = self:on_replace(pos, oldnode, newnode)
|
|
||||||
|
local oldnode = what
|
||||||
|
local newnode = with
|
||||||
|
|
||||||
|
-- convert any group: replacements to actual node name
|
||||||
|
if oldnode:find("group:") then
|
||||||
|
oldnode = minetest.get_node(pos).name
|
||||||
end
|
end
|
||||||
|
|
||||||
if on_replace_return ~= false then
|
if self:on_replace(pos, oldnode, newnode) == false then
|
||||||
minetest.set_node(pos, {name = with})
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
minetest.set_node(pos, {name = with})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user