Compare commits

..

No commits in common. "9d7aeb5fdd8c4e86ae87b659df82bc44ce3991b0" and "2624ea4e737ffa16de74a2179e2487a7e8e00c9c" have entirely different histories.

2 changed files with 40 additions and 6 deletions

View File

@ -1,9 +1,8 @@
===ITEM_DROP MOD for MINETEST-C55===
by PilzAdam
small changes by Iqualfragile
Introduction:
This mod adds Minecraft like pick up of items to Minetest.
This mod adds Minecraft like drop/pick up of items to Minetest.
How to install:
Unzip the archive an place it in minetest-base-directory/mods/minetest/

View File

@ -6,7 +6,7 @@ minetest.register_globalstep(function(dtime)
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 1)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
inv:add_item("main", ItemStack(object:get_luaentity().itemstring))
if object:get_luaentity().itemstring ~= "" then
minetest.sound_play("item_drop_pickup", {
@ -22,7 +22,7 @@ minetest.register_globalstep(function(dtime)
for _,object in ipairs(minetest.env:get_objects_inside_radius(pos, 2)) do
if not object:is_player() and object:get_luaentity() and object:get_luaentity().name == "__builtin:item" then
if object:get_luaentity().collect then
if inv and inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if inv:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
local pos1 = pos
pos1.y = pos1.y+0.2
local pos2 = object:getpos()
@ -52,12 +52,47 @@ minetest.register_globalstep(function(dtime)
end, {player, object})
end
else
minetest.after(0.5, function(entity)
entity.collect = true
end, object:get_luaentity())
end
end
end
end
end)
if minetest.setting_get("log_mods") then
minetest.log("action", "item_drop loaded")
function minetest.handle_node_drops(pos, drops, digger)
for _,item in ipairs(drops) do
local count, name
if type(item) == "string" then
count = 1
name = item
else
count = item:get_count()
name = item:get_name()
end
for i=1,count do
local obj = minetest.env:add_item(pos, name)
if obj ~= nil then
obj:get_luaentity().collect = true
local x = math.random(1, 5)
if math.random(1,2) == 1 then
x = -x
end
local z = math.random(1, 5)
if math.random(1,2) == 1 then
z = -z
end
obj:setvelocity({x=1/x, y=obj:getvelocity().y, z=1/z})
-- FIXME this doesnt work for deactiveted objects
if minetest.setting_get("remove_items") and tonumber(minetest.setting_get("remove_items")) then
minetest.after(tonumber(minetest.setting_get("remove_items")), function(obj)
obj:remove()
end, obj)
end
end
end
end
end