mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-01 07:13:45 +01:00
Clean up code
This commit is contained in:
parent
c6db032674
commit
2c7039fdda
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user