mirror of
https://files.creativekara.fr/git/poschangelib.git
synced 2024-12-04 21:13:50 +01:00
Fix trigger_meta on stomp.
This commit is contained in:
parent
70327770e1
commit
994b37314c
16
stomping.lua
16
stomping.lua
@ -41,12 +41,12 @@ function poschangelib.get_footprint_node_name(source_node_name, mod_name)
|
||||
end
|
||||
|
||||
--- poschangelib walk callback
|
||||
local function walk_listener(player, pos, node, desc)
|
||||
poschangelib.chance_stomp(player, pos, node, node_desc)
|
||||
local function walk_listener(player, pos, node, desc, trigger_meta)
|
||||
poschangelib.chance_stomp(player, pos, node, desc, trigger_meta)
|
||||
end
|
||||
|
||||
--- Random roll and do the stomp if it succeeds.
|
||||
function poschangelib.chance_stomp(player, pos, node, node_desc)
|
||||
function poschangelib.chance_stomp(player, pos, node, node_desc, trigger_meta)
|
||||
local stomp_desc = stomps[node.name]
|
||||
if not stomp_desc then
|
||||
minetest.log('warning', 'No stomping data found for node ' .. node.name)
|
||||
@ -54,7 +54,7 @@ function poschangelib.chance_stomp(player, pos, node, node_desc)
|
||||
end
|
||||
for i, s_desc in ipairs(stomp_desc) do
|
||||
if (math.random() * s_desc.chance) < 1.0 then
|
||||
poschangelib.do_stomp(player, pos, node, node_desc, s_desc)
|
||||
poschangelib.do_stomp(player, pos, node, node_desc, s_desc, trigger_meta)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -66,7 +66,8 @@ end
|
||||
-- @param node Node being stomped.
|
||||
-- @param node_desc Description of the node being stomped.
|
||||
-- @param stomp_desc Optional stomp description. If not provided it looks for it.
|
||||
function poschangelib.do_stomp(player, pos, node, node_desc, stomp_desc)
|
||||
-- @param trigger_meta Optional trigger meta, passed by walk listeners.
|
||||
function poschangelib.do_stomp(player, pos, node, node_desc, stomp_desc, trigger_meta)
|
||||
if not stomp_desc then
|
||||
stomp_desc = stomps[node.name]
|
||||
if stomp_desc then stomp_desc = stomp_desc[1] end
|
||||
@ -75,9 +76,14 @@ function poschangelib.do_stomp(player, pos, node, node_desc, stomp_desc)
|
||||
minetest.log('warning', 'No stomping data found for node ' .. node.name)
|
||||
return
|
||||
end
|
||||
if not trigger_meta then trigger_meta = {} end
|
||||
if type(stomp_desc.dest_node_name) == 'function' then
|
||||
local dest_node = stomp_desc.dest_node_name(player, pos, node, trigger_meta)
|
||||
if not dest_node then return end
|
||||
if not dest_node.name then
|
||||
minetest.log('error', 'Stomping: function did not set node name for ' .. node.name)
|
||||
return
|
||||
end
|
||||
minetest.set_node(pos, dest_node)
|
||||
else
|
||||
local new_node = minetest.get_node(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user