Make item entities a bit more efficient
This commit is contained in:
parent
719f7b5b77
commit
ba97dfd02f
|
@ -88,6 +88,15 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
-- Magnet
|
-- Magnet
|
||||||
else
|
else
|
||||||
|
--move this to the front so players can see animation before collection
|
||||||
|
if not collected then
|
||||||
|
if object:get_luaentity()._magnet_timer > 1 then
|
||||||
|
object:get_luaentity()._magnet_timer = -item_drop_settings.magnet_time
|
||||||
|
object:get_luaentity()._magnet_active = false
|
||||||
|
elseif object:get_luaentity()._magnet_timer < 0 then
|
||||||
|
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
object:get_luaentity()._magnet_active = true
|
object:get_luaentity()._magnet_active = true
|
||||||
object:get_luaentity()._collector_timer = 0
|
object:get_luaentity()._collector_timer = 0
|
||||||
|
@ -95,11 +104,7 @@ minetest.register_globalstep(function(dtime)
|
||||||
-- Move object to player
|
-- Move object to player
|
||||||
disable_physics(object, object:get_luaentity())
|
disable_physics(object, object:get_luaentity())
|
||||||
|
|
||||||
local opos = object:get_pos()
|
object:move_to(checkpos)
|
||||||
local vec = vector.subtract(checkpos, opos)
|
|
||||||
vec = vector.add(opos, vector.divide(vec, 2))
|
|
||||||
object:move_to(vec)
|
|
||||||
|
|
||||||
|
|
||||||
--fix eternally falling items
|
--fix eternally falling items
|
||||||
minetest.after(0, function(object)
|
minetest.after(0, function(object)
|
||||||
|
@ -143,15 +148,6 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not collected then
|
|
||||||
if object:get_luaentity()._magnet_timer > 1 then
|
|
||||||
object:get_luaentity()._magnet_timer = -item_drop_settings.magnet_time
|
|
||||||
object:get_luaentity()._magnet_active = false
|
|
||||||
elseif object:get_luaentity()._magnet_timer < 0 then
|
|
||||||
object:get_luaentity()._magnet_timer = object:get_luaentity()._magnet_timer + dtime
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user