mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-17 15:58:26 +01:00
Eject items when a node is placed at their current pos
This commit is contained in:
parent
a6ce72a093
commit
7dc287e014
28
mods/_misc/eject_entities.lua
Executable file
28
mods/_misc/eject_entities.lua
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
-------------------------------------
|
||||||
|
-- Eject entities when placing node
|
||||||
|
--
|
||||||
|
|
||||||
|
unwalkable_nodes = {}
|
||||||
|
|
||||||
|
minetest.after(0, function()
|
||||||
|
for itemname, node in pairs(minetest.registered_nodes) do
|
||||||
|
if node.walkable == false then
|
||||||
|
table.insert(unwalkable_nodes, 1, itemname)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_on_placenode(function(pos)
|
||||||
|
local objs = minetest.get_objects_inside_radius(pos, 1)
|
||||||
|
local minp, maxp = {x=pos.x-1, y=pos.y, z=pos.z-1}, {x=pos.x+1, y=pos.y+1, z=pos.z+1}
|
||||||
|
local nodes = minetest.find_nodes_in_area(minp, maxp, unwalkable_nodes)
|
||||||
|
if table.getn(nodes) == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
for _,obj in pairs(objs) do
|
||||||
|
if not obj:is_player() and obj:get_entity_name() == "builtin:item" then
|
||||||
|
obj:setpos(nodes[math.random(1,#nodes)])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
@ -27,3 +27,6 @@ dofile(minetest.get_modpath("_misc").."/uncraft_woll.lua")
|
|||||||
|
|
||||||
-- List players
|
-- List players
|
||||||
dofile(minetest.get_modpath("_misc").."/list_players.lua")
|
dofile(minetest.get_modpath("_misc").."/list_players.lua")
|
||||||
|
|
||||||
|
-- Eject entites when putting a node
|
||||||
|
dofile(minetest.get_modpath("_misc").."/eject_entities.lua")
|
||||||
|
Loading…
Reference in New Issue
Block a user