mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2025-01-26 01:30:29 +01:00
[item_drop] Make pickup delay absolute (not wait anymore, as it actually was)
This commit is contained in:
parent
f45c080dc0
commit
33bbc85934
@ -19,6 +19,7 @@ local pickup_duration = 0.2
|
|||||||
local pickup_inv_duration = 1/pickup_duration-0.2
|
local pickup_inv_duration = 1/pickup_duration-0.2
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
|
local tstamp = minetest.get_us_time()
|
||||||
for _,player in ipairs(minetest.get_connected_players()) do
|
for _,player in ipairs(minetest.get_connected_players()) do
|
||||||
if player:get_hp() > 0 or not enable_damage then
|
if player:get_hp() > 0 or not enable_damage then
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
@ -28,13 +29,10 @@ minetest.register_globalstep(function(dtime)
|
|||||||
for _,object in ipairs(minetest.get_objects_inside_radius(pos, scan_range)) do
|
for _,object in ipairs(minetest.get_objects_inside_radius(pos, scan_range)) do
|
||||||
local luaEnt = object:get_luaentity()
|
local luaEnt = object:get_luaentity()
|
||||||
if not object:is_player() and luaEnt and luaEnt.name == "__builtin:item" then
|
if not object:is_player() and luaEnt and luaEnt.name == "__builtin:item" then
|
||||||
local ticky = luaEnt.item_drop_delay
|
local ticky = luaEnt.item_drop_min_tstamp
|
||||||
if ticky then
|
if ticky then
|
||||||
ticky = ticky - dtime
|
if tstamp >= ticky then
|
||||||
if ticky <= 0 then
|
luaEnt.item_drop_min_tstamp = nil
|
||||||
luaEnt.item_drop_delay = nil
|
|
||||||
else
|
|
||||||
luaEnt.item_drop_delay = ticky
|
|
||||||
end
|
end
|
||||||
elseif not luaEnt.item_drop_nopickup then
|
elseif not luaEnt.item_drop_nopickup then
|
||||||
-- Point-line distance computation, heavily simplified since the wanted line,
|
-- Point-line distance computation, heavily simplified since the wanted line,
|
||||||
@ -142,7 +140,7 @@ function minetest.item_drop(itemstack, dropper, pos)
|
|||||||
v.y = v.y*2 + 2
|
v.y = v.y*2 + 2
|
||||||
v.z = v.z*2
|
v.z = v.z*2
|
||||||
obj:setvelocity(v)
|
obj:setvelocity(v)
|
||||||
obj:get_luaentity().item_drop_delay = delay_before_playerdrop_pickup
|
obj:get_luaentity().item_drop_min_tstamp = minetest.get_us_time() + delay_before_playerdrop_pickup * 1000000
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
core.add_item(pos, itemstack)
|
core.add_item(pos, itemstack)
|
||||||
|
Loading…
Reference in New Issue
Block a user