Always collect items one by one

This commit is contained in:
Hybrid Dog 2017-09-12 10:13:49 +02:00
parent 0f903cd0b0
commit e7b8d02922

View File

@ -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,36 +151,33 @@ 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 vel = vector.multiply(
local distance = vector.distance(pos, pos2) vector.subtract(pos, pos2), 3)
got_item = true vel.y = vel.y + 0.6
if distance <= pickup_radius then object:setvelocity(vel)
collect_item(ent, pos, player) if ent.physical_state then
else ent.physical_state = false
local vel = vector.multiply( ent.object:set_properties({
vector.subtract(pos, pos2), 3) physical = false
vel.y = vel.y + 0.6 })
object:setvelocity(vel)
if ent.physical_state then
ent.physical_state = false
ent.object:set_properties({
physical = false
})
minetest.after(magnet_time, afterflight, minetest.after(magnet_time, afterflight,
object, inv, player) object, inv, player)
end
end end
end end
end end
end end
return got_item
end end
local function pickup_step() local function pickup_step()