Clean up code

This commit is contained in:
ancientmarinerdev 2023-03-14 21:33:14 +00:00 committed by Gitea
parent c6db032674
commit 2c7039fdda

View file

@ -119,7 +119,7 @@ local function retrieve_close_spreadable_nodes (p)
return nn return nn
end end
local function sculk_stuff (p, xp_amount) local function spread_sculk (p, xp_amount)
local c = minetest.find_node_near(p,SPREAD_RANGE,{"mcl_sculk:catalyst"}) local c = minetest.find_node_near(p,SPREAD_RANGE,{"mcl_sculk:catalyst"})
if c then if c then
local nn = retrieve_close_spreadable_nodes (p) local nn = retrieve_close_spreadable_nodes (p)
@ -141,9 +141,8 @@ local function sculk_stuff (p, xp_amount)
local r = math.min(math.random(#nn), xp_amount) local r = math.min(math.random(#nn), xp_amount)
--minetest.log("r: ".. r)
minetest.log("r: ".. r)
for i=1,r do for i=1,r do
minetest.set_node(nn[i],{name = "mcl_sculk:sculk" }) minetest.set_node(nn[i],{name = "mcl_sculk:sculk" })
set_node_xp(nn[i],math.floor(xp_amount / r)) set_node_xp(nn[i],math.floor(xp_amount / r))
@ -164,15 +163,9 @@ local function sculk_stuff (p, xp_amount)
end end
function mcl_sculk.handle_death(pos, xp_amount) function mcl_sculk.handle_death(pos, xp_amount)
if not pos or not xp_amount then return end
--local nu = minetest.get_node(vector.offset(p,0,-1,0)) --local nu = minetest.get_node(vector.offset(p,0,-1,0))
local c = minetest.find_node_near(pos ,SPREAD_RANGE,{"mcl_sculk:catalyst"}) return spread_sculk (pos, xp_amount)
if c then
local nn = retrieve_close_spreadable_nodes (pos)
if nn and #nn > 0 then
return sculk_stuff (pos, xp_amount)
end
end
end end
minetest.register_on_dieplayer(function(player) minetest.register_on_dieplayer(function(player)