1
0
mirror of https://github.com/sys4-fr/server-nalc.git synced 2024-12-25 02:00:37 +01:00

[item_drop] Optimize a bit; reduce ticking rate to 0.2s

This commit is contained in:
Wouters Dorian 2015-07-31 14:45:46 +02:00
parent 1e6b0d0305
commit 54b20364fd

View File

@ -26,9 +26,10 @@ minetest.register_globalstep(function(dtime)
pos.y = pos.y + 0.9 pos.y = pos.y + 0.9
local inv = player:get_inventory() local inv = player:get_inventory()
if inv then
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 and luaEnt and luaEnt.name == "__builtin:item" then
local ticky = luaEnt.item_drop_min_tstamp local ticky = luaEnt.item_drop_min_tstamp
if ticky then if ticky then
if tstamp >= ticky then if tstamp >= ticky then
@ -47,7 +48,7 @@ minetest.register_globalstep(function(dtime)
local playerDistance = dX*dX+dZ*dZ local playerDistance = dX*dX+dZ*dZ
if playerDistance <= pickup_range_squared then if playerDistance <= pickup_range_squared then
local itemStack = ItemStack(luaEnt.itemstring) local itemStack = ItemStack(luaEnt.itemstring)
if inv and inv:room_for_item("main", itemStack) then if inv:room_for_item("main", itemStack) then
local pos1 = pos local pos1 = pos
pos1.y = pos1.y-player_half_height+0.5 pos1.y = pos1.y-player_half_height+0.5
local vec = {x=dX, y=pos1.y-pos2.y, z=dZ} local vec = {x=dX, y=pos1.y-pos2.y, z=dZ}
@ -90,6 +91,7 @@ minetest.register_globalstep(function(dtime)
end end
end end
end end
end
end) end)
function minetest.handle_node_drops(pos, drops, digger) function minetest.handle_node_drops(pos, drops, digger)