mirror of
https://github.com/minetest-mods/item_drop.git
synced 2024-12-22 22:02:26 +01:00
Merge pull request #6 from minetest-mods/no_pop
Always collect items one by one
This commit is contained in:
commit
7afe3723e4
22
init.lua
22
init.lua
@ -123,7 +123,7 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
|
|||||||
return keys_pressed ~= key_invert
|
return keys_pressed ~= key_invert
|
||||||
end
|
end
|
||||||
|
|
||||||
-- this function is called for each player to possibly collect items
|
-- called for each player to possibly collect an item, returns true if so
|
||||||
local function pickupfunc(player)
|
local function pickupfunc(player)
|
||||||
if not keys_pressed(player)
|
if not keys_pressed(player)
|
||||||
or not minetest.get_player_privs(player:get_player_name()).interact
|
or not minetest.get_player_privs(player:get_player_name()).interact
|
||||||
@ -134,7 +134,6 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
|
|||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
pos.y = pos.y+0.5
|
pos.y = pos.y+0.5
|
||||||
local inv
|
local inv
|
||||||
local got_item = false
|
|
||||||
|
|
||||||
local objectlist = minetest.get_objects_inside_radius(pos,
|
local objectlist = minetest.get_objects_inside_radius(pos,
|
||||||
magnet_mode and magnet_radius or pickup_radius)
|
magnet_mode and magnet_radius or pickup_radius)
|
||||||
@ -152,18 +151,17 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
|
|||||||
end
|
end
|
||||||
local item = ItemStack(ent.itemstring)
|
local item = ItemStack(ent.itemstring)
|
||||||
if inv:room_for_item("main", item) then
|
if inv:room_for_item("main", item) then
|
||||||
if zero_velocity_mode then
|
local flying_item
|
||||||
-- collect one item at a time in zero velocity mode
|
local pos2
|
||||||
-- to avoid the loud pop
|
if magnet_mode then
|
||||||
|
pos2 = object:getpos()
|
||||||
|
flying_item = vector.distance(pos, pos2) > pickup_radius
|
||||||
|
end
|
||||||
|
if not flying_item then
|
||||||
|
-- collect one item at a time to avoid the loud pop
|
||||||
collect_item(ent, pos, player)
|
collect_item(ent, pos, player)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
local pos2 = object:getpos()
|
|
||||||
local distance = vector.distance(pos, pos2)
|
|
||||||
got_item = true
|
|
||||||
if distance <= pickup_radius then
|
|
||||||
collect_item(ent, pos, player)
|
|
||||||
else
|
|
||||||
local vel = vector.multiply(
|
local vel = vector.multiply(
|
||||||
vector.subtract(pos, pos2), 3)
|
vector.subtract(pos, pos2), 3)
|
||||||
vel.y = vel.y + 0.6
|
vel.y = vel.y + 0.6
|
||||||
@ -181,8 +179,6 @@ if minetest.settings:get_bool("item_drop.enable_item_pickup") ~= false then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return got_item
|
|
||||||
end
|
|
||||||
|
|
||||||
local function pickup_step()
|
local function pickup_step()
|
||||||
local got_item
|
local got_item
|
||||||
|
Loading…
Reference in New Issue
Block a user