diff --git a/minetest.conf b/minetest.conf index ce9e01f..8e5a25e 100644 --- a/minetest.conf +++ b/minetest.conf @@ -2,6 +2,9 @@ mg_flags = caves, notrees #physics + #disable fast (since its used to pick up drops) +movement_acceleration_fast = 2 +movement_speed_fast = 4 movement_liquid_sink = 25 movement_speed_jump = 6.2 diff --git a/mods/builtin_item/init.lua b/mods/builtin_item/init.lua index f8aa338..92129e5 100644 --- a/mods/builtin_item/init.lua +++ b/mods/builtin_item/init.lua @@ -34,16 +34,16 @@ minetest.register_entity(":__builtin:item", { visual = "sprite", textures = {"unknown_item.png"} } - if item_texture and item_texture ~= "" then + --[[if item_texture and item_texture ~= "" then prop.visual = "sprite" prop.textures = {item_texture} prop.visual_size = {x=0.50, y=0.50} - else + else]] prop.visual = "wielditem" prop.textures = {itemname} prop.visual_size = {x=0.20, y=0.20} prop.automatic_rotate = math.pi * 0.25 - end + --end self.object:set_properties(prop) end, 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..ca90b2c --- /dev/null +++ b/mods/item_drop/init.lua @@ -0,0 +1,118 @@ +minetest.register_globalstep(function(dtime) + for _,player in ipairs(minetest.get_connected_players()) do + if player:get_hp() > 0 or not minetest.setting_getbool("enable_damage") then + local pos = player:getpos() + local controls = player:get_player_control() + pos.y = pos.y+0.5 + local inv = player:get_inventory() + local objcts1 = minetest.env:get_objects_inside_radius(pos, 1) + local objcts2 = minetest.env:get_objects_inside_radius(pos, 2) + for _,object in ipairs(objcts1) 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)) and controls.aux1 then + inv:add_item("main", ItemStack(object:get_luaentity().itemstring)) + if object:get_luaentity().itemstring ~= "" then + minetest.sound_play("item_drop_pickup", { + to_player = player:get_player_name(), + gain = 0.4*(1/#objcts1 or 1), + }) + end + object:get_luaentity().itemstring = "" + object:remove() + end + end + end + + for _,object in ipairs(objcts2) 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)) and controls.aux1 then + local pos1 = pos + pos1.y = pos1.y+0.2 + local pos2 = object:getpos() + local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z} + vec.x = vec.x*3 + vec.y = vec.y*3 + vec.z = vec.z*3 + object:setvelocity(vec) + object:get_luaentity().physical_state = false + object:get_luaentity().object:set_properties({ + physical = false + }) + -- TODO: is that necessary?? + minetest.after(1, function(args) + local lua = object:get_luaentity() + if object == nil or lua == nil or lua.itemstring == nil then + return + end + 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", { + to_player = player:get_player_name(), + gain = 0.4*(1/#objcts2 or 1), + }) + end + object:get_luaentity().itemstring = "" + object:remove() + else + object:setvelocity({x=0,y=0,z=0}) + object:get_luaentity().physical_state = true + object:get_luaentity().object:set_properties({ + physical = true + }) + end + end, {player, object}) + + end + end + end + end + end + end +end) + +function minetest.handle_node_drops(pos, drops, digger) + local inv + if minetest.setting_getbool("creative_mode") and digger and digger:is_player() then + inv = digger:get_inventory() + end + 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 + if not inv or not inv:contains_item("main", ItemStack(name)) then + 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 +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