add a new item drop mod
parent
0627fcd8cb
commit
889184b45e
|
@ -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 <sam@hocevar.net>
|
||||
|
||||
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.
|
|
@ -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
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue