pick dropped items when holding shift (sneak)
parent
9e0e474f89
commit
2123530202
46
README.md
46
README.md
|
@ -33,4 +33,48 @@ TODO:
|
||||||
Detect AFK player
|
Detect AFK player
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
AFK (away from keyboard) is detected when player doesn't move for certain time, player will sit down.
|
AFK (away from keyboard) is detected when player doesn't move for certain time, player will sit down.
|
||||||
|
|
||||||
|
===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.
|
||||||
|
|
7
init.lua
7
init.lua
|
@ -38,6 +38,13 @@ if SPAWN_POINT then
|
||||||
print("[Mod][enhancements] SPAWN_POINT enabled")
|
print("[Mod][enhancements] SPAWN_POINT enabled")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- pick dropped items by holding shift (sneak)
|
||||||
|
if ITEM_DROP then
|
||||||
|
dofile(minetest.get_modpath("enhancements").."/item_drop.lua")
|
||||||
|
|
||||||
|
print("[Mod][enhancements] ITEM_DROP enabled")
|
||||||
|
end
|
||||||
|
|
||||||
-- manage privileges i areas mod - if using areas mod only for admin purposes
|
-- manage privileges i areas mod - if using areas mod only for admin purposes
|
||||||
-- WIP DONT ENABLE!
|
-- WIP DONT ENABLE!
|
||||||
if AREAS_ENHANCE and minetest.get_modpath("areas") then
|
if AREAS_ENHANCE and minetest.get_modpath("areas") then
|
||||||
|
|
|
@ -0,0 +1,82 @@
|
||||||
|
minetest.register_globalstep(function(dtime)
|
||||||
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
|
if player:get_player_control().sneak and (player:get_hp() > 0 or not minetest.setting_getbool("enable_damage")) then
|
||||||
|
|
||||||
|
if player:get_player_control().aux1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
pick_dropped_items(player)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
function pick_dropped_items(player)
|
||||||
|
local pos = player:getpos()
|
||||||
|
pos.y = pos.y+0.5
|
||||||
|
local inv = player:get_inventory()
|
||||||
|
|
||||||
|
--collection
|
||||||
|
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
|
||||||
|
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", {
|
||||||
|
to_player = player:get_player_name(),
|
||||||
|
gain = 0.4,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
object:get_luaentity().itemstring = ""
|
||||||
|
object:remove()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--magnet
|
||||||
|
for _,object in ipairs(minetest.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
|
||||||
|
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:moveto(vec)
|
||||||
|
object:get_luaentity().physical_state = false
|
||||||
|
object:get_luaentity().object:set_properties({
|
||||||
|
physical = false
|
||||||
|
})
|
||||||
|
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
object:get_luaentity().itemstring = ""
|
||||||
|
object:remove()
|
||||||
|
else
|
||||||
|
object:moveto(pos, false)
|
||||||
|
object:get_luaentity().physical_state = true
|
||||||
|
object:get_luaentity().object:set_properties({
|
||||||
|
physical = true
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end, {player, object})
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,4 +3,5 @@ CLEAN_UNKNOWN = true
|
||||||
EXTERNAL_CMD = true
|
EXTERNAL_CMD = true
|
||||||
PLAYER_AFK = true
|
PLAYER_AFK = true
|
||||||
SPAWN_POINT = true
|
SPAWN_POINT = true
|
||||||
|
ITEM_DROP = true
|
||||||
AREAS_ENHANCE = false
|
AREAS_ENHANCE = false
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue