1 minetest
.register_globalstep(function(dtime
)
2 for _
,player
in ipairs(minetest
.get_connected_players()) do
3 if player
:get_hp() > 0 or not minetest
.setting_getbool("enable_damage") then
4 local pos
= player
:getpos()
6 local inv
= player
:get_inventory()
7 local ctrl
= player
:get_player_control()
8 if ctrl
.up
or ctrl
.left
or ctrl
.right
then
10 for _
,object
in ipairs(minetest
.env
:get_objects_inside_radius(pos
, 2)) do
11 local en
= object
:get_luaentity()
12 if not object
:is_player() and en
and en
.name
== "__builtin:item" then
14 inv
:room_for_item("main", ItemStack(en
.itemstring
)) then
15 inv
:add_item("main", ItemStack(en
.itemstring
))
16 if en
.itemstring
~= "" then
17 minetest
.sound_play("item_drop_pickup", {
18 to_player
= player
:get_player_name(),
33 function minetest
.handle_node_drops(pos
, drops
, digger
)
35 if minetest
.setting_getbool("creative_mode") and digger
and digger
:is_player() then
36 inv
= digger
:get_inventory()
38 for _
,item
in ipairs(drops
) do
40 if type(item
) == "string" then
44 count
= item
:get_count()
45 name
= item
:get_name()
47 if not inv
or not inv
:contains_item("main", ItemStack(name
)) then
49 local obj
= minetest
.env
:add_item(pos
, name
)
51 obj
:get_luaentity().collect
= true
52 local x
= math
.random(1, 5)
53 if math
.random(1,2) == 1 then
56 local z
= math
.random(1, 5)
57 if math
.random(1,2) == 1 then
60 obj
:setvelocity({x
=1/x
, y
=obj
:getvelocity().y
, z
=1/z
})
62 -- FIXME this doesnt work for deactiveted objects
63 if minetest
.setting_get("remove_items") and tonumber(minetest
.setting_get("remove_items")) then
64 minetest
.after(tonumber(minetest
.setting_get("remove_items")), function(obj
)