diff --git a/mods/item_drop/README.txt b/mods/item_drop/README.txt new file mode 100644 index 0000000..fe43054 --- /dev/null +++ b/mods/item_drop/README.txt @@ -0,0 +1,42 @@ +===ITEM_DROP MOD for MINETEST-C55=== +by PilzAdam + +Introduction: +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/ +if you have a windows client or a linux run-in-place client. If you have +a linux system-wide instalation place it in ~/.minetest/mods/minetest/. +If you want to install this mod only in one world create the folder +worldmods/ in your worlddirectory. +For further information or help see: +http://wiki.minetest.com/wiki/Installing_Mods + +How to use the mod: +Just install it an everything works. + +For developers: +You dont have to use get_drops() anymore because of changes in the +builtin files of minetest. + +License: +Sourcecode: WTFPL (see below) +Sound: WTFPL (see below) + +See also: +http://minetest.net/ + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2004 Sam Hocevar + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/mods/item_drop/init.lua b/mods/item_drop/init.lua new file mode 100644 index 0000000..8864ef0 --- /dev/null +++ b/mods/item_drop/init.lua @@ -0,0 +1,46 @@ +local timer = -1 + +local item_entity = minetest.registered_entities["__builtin:item"] +local old_on_activate = item_entity.on_activate or function()end +item_entity.on_activate = function(self, staticdata, dtime_s) + old_on_activate(self, staticdata, dtime_s) + timer = -1 +end + +minetest.register_globalstep(function(dtime) + timer = timer+dtime + if timer < 0.1 then + return + end + timer = 0 + for _,player in ipairs(minetest.get_connected_players()) do + local pos = player:getpos() + pos.y = pos.y+0.5 + local inv = player:get_inventory() + + for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do + if not object:is_player() + and object:get_luaentity() + and object:get_luaentity().name == "__builtin:item" then + local str = object:get_luaentity().itemstring + local item = ItemStack(str) + if inv + and inv:room_for_item("main", item) then + if str ~= "" then + minetest.sound_play("item_drop_pickup", { + to_player = player:get_player_name(), + }) + object:get_luaentity().itemstring = "" + inv:add_item("main", item) + end + object:remove() + end + end + end + end +end) + + +if minetest.setting_get("log_mods") then + minetest.log("action", "item_drop loaded") +end diff --git a/mods/item_drop/sounds/item_drop_pickup.1.ogg b/mods/item_drop/sounds/item_drop_pickup.1.ogg new file mode 100644 index 0000000..2ae432d Binary files /dev/null and b/mods/item_drop/sounds/item_drop_pickup.1.ogg differ diff --git a/mods/item_drop/sounds/item_drop_pickup.2.ogg b/mods/item_drop/sounds/item_drop_pickup.2.ogg new file mode 100644 index 0000000..f58bf08 Binary files /dev/null and b/mods/item_drop/sounds/item_drop_pickup.2.ogg differ diff --git a/mods/item_drop/sounds/item_drop_pickup.3.ogg b/mods/item_drop/sounds/item_drop_pickup.3.ogg new file mode 100644 index 0000000..cf57c94 Binary files /dev/null and b/mods/item_drop/sounds/item_drop_pickup.3.ogg differ diff --git a/mods/item_drop/sounds/item_drop_pickup.4.ogg b/mods/item_drop/sounds/item_drop_pickup.4.ogg new file mode 100644 index 0000000..bfe99d9 Binary files /dev/null and b/mods/item_drop/sounds/item_drop_pickup.4.ogg differ