mirror of
https://files.creativekara.fr/git/poschangelib.git
synced 2024-08-20 05:14:11 +02:00
Enhance stomp usage.
This commit is contained in:
parent
937ee8ac66
commit
4cc361ea41
@ -237,17 +237,17 @@ function poschangelib.trigger_stomp(player, pos_to_stomp, chance_factor)
|
|||||||
local node = minetest.get_node(pos_to_stomp)
|
local node = minetest.get_node(pos_to_stomp)
|
||||||
local node_desc = minetest.registered_nodes[node.name]
|
local node_desc = minetest.registered_nodes[node.name]
|
||||||
if not node_desc or not stomps[node.name] or #stomps[node.name] == 0 then
|
if not node_desc or not stomps[node.name] or #stomps[node.name] == 0 then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
local stomp_desc = stomps[node.name]
|
local stomp_desc = stomps[node.name]
|
||||||
if not stomp_desc then
|
if not stomp_desc then
|
||||||
return
|
return false
|
||||||
end
|
end
|
||||||
if chance_factor == nil then chance_factor = 1.0 end
|
if chance_factor == nil then chance_factor = 1.0 end
|
||||||
for i, s_desc in ipairs(stomp_desc) do
|
for i, s_desc in ipairs(stomp_desc) do
|
||||||
if (math.random() * s_desc.chance) < (1.0 * chance_factor) then
|
if (math.random() * s_desc.chance) < (1.0 * chance_factor) then
|
||||||
poschangelib.do_stomp(player, pos_to_stomp, node, node_desc, s_desc)
|
poschangelib.do_stomp(player, pos_to_stomp, node, node_desc, s_desc)
|
||||||
return
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user