Compare commits

...

6 Commits

Author SHA1 Message Date
iqualfragile 9d7aeb5fdd Update README.txt 2012-12-13 18:55:37 +01:00
iqualfragile 975fb7e9a7 removed the item_drop-funcitonaltiy left item_pick
up
2012-12-13 18:54:26 +01:00
PilzAdam a41ddb6705 Log mod load if log_mod is set to true 2012-10-07 19:44:16 +02:00
PilzAdam 8b8a838882 Merge pull request #1 from cornernote/patch-1
fix server crash when player exits during loop
2012-10-06 09:14:06 -07:00
PilzAdam 12fdaab4cb Make it easier to drop items 2012-10-04 20:17:10 +02:00
cornernote 076ebbe0f4 fix server crash when player exits during loop 2012-10-04 12:22:44 +09:30
2 changed files with 6 additions and 40 deletions

View File

@ -1,8 +1,9 @@
===ITEM_DROP MOD for MINETEST-C55===
by PilzAdam
small changes by Iqualfragile
Introduction:
This mod adds Minecraft like drop/pick up of items to Minetest.
This mod adds Minecraft like 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:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if inv and 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:room_for_item("main", ItemStack(object:get_luaentity().itemstring)) then
if inv and 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,47 +52,12 @@ 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)
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
if minetest.setting_get("log_mods") then
minetest.log("action", "item_drop loaded")
end