mirror of
https://github.com/minetest-mods/drawers.git
synced 2024-11-22 14:43:45 +01:00
Randomize drop pos
This commit is contained in:
parent
69a974cb6b
commit
a53dac2929
@ -98,10 +98,11 @@ function drawers.drawer_on_dig(pos, node, player)
|
|||||||
local j = math.floor(count / stack_max) + 1
|
local j = math.floor(count / stack_max) + 1
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= j do
|
while i <= j do
|
||||||
|
rndpos = drawers.randomize_pos(pos)
|
||||||
if not (i == j) then
|
if not (i == j) then
|
||||||
core.add_item(pos, name .. " " .. stack_max)
|
core.add_item(rndpos, name .. " " .. stack_max)
|
||||||
else
|
else
|
||||||
core.add_item(pos, name .. " " .. count % stack_max)
|
core.add_item(rndpos, name .. " " .. count % stack_max)
|
||||||
end
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
@ -149,3 +149,13 @@ function drawers.spawn_visual(pos)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function drawers.randomize_pos(pos)
|
||||||
|
local rndpos = table.copy(pos)
|
||||||
|
local x = math.random(-50, 50) * 0.01
|
||||||
|
local z = math.random(-50, 50) * 0.01
|
||||||
|
rndpos.x = rndpos.x + x
|
||||||
|
rndpos.y = rndpos.y + 0.25
|
||||||
|
rndpos.z = rndpos.z + z
|
||||||
|
return rndpos
|
||||||
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user