make xp.throw_xp return the orb objects

This commit is contained in:
cora 2022-09-08 13:16:26 +02:00
parent a6021e7601
commit 6da1491f14
2 changed files with 4 additions and 2 deletions

@ -136,7 +136,7 @@ end
function mcl_experience.throw_xp(pos, total_xp) function mcl_experience.throw_xp(pos, total_xp)
local i, j = 0, 0 local i, j = 0, 0
local obs = {}
while i < total_xp and j < 100 do while i < total_xp and j < 100 do
local xp = math.min(math.random(1, math.min(32767, total_xp - math.floor(i / 2))), total_xp - i) local xp = math.min(math.random(1, math.min(32767, total_xp - math.floor(i / 2))), total_xp - i)
local obj = minetest.add_entity(pos, "mcl_experience:orb", tostring(xp)) local obj = minetest.add_entity(pos, "mcl_experience:orb", tostring(xp))
@ -153,7 +153,9 @@ function mcl_experience.throw_xp(pos, total_xp)
i = i + xp i = i + xp
j = j + 1 j = j + 1
table.insert(obs,obj)
end end
return obs
end end
function mcl_experience.remove_hud(player) function mcl_experience.remove_hud(player)

@ -126,7 +126,7 @@ minetest.registered_entities["mcl_experience:orb"].on_step = function(self,dtime
if n.name == "mcl_sculk:sculk" and not self._sculkdrop then if n.name == "mcl_sculk:sculk" and not self._sculkdrop then
local c = minetest.find_node_near(p,range,{"mcl_sculk:catalyst"}) local c = minetest.find_node_near(p,range,{"mcl_sculk:catalyst"})
if c then if c then
local nnn = minetest.find_nodes_in_area(vector.offset(p,-range,-2,-range),vector.offset(p,range,2,range),spread_to) local nnn = minetest.find_nodes_in_area(vector.offset(p,-range,-range,-range),vector.offset(p,range,range,range),spread_to)
local nn={} local nn={}
for _,v in pairs(nnn) do for _,v in pairs(nnn) do
if has_air(v) then if has_air(v) then