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