small fix, added the ability to enable debug for debugging code
Some checks failed
luacheck / luacheck (push) Has been cancelled

This commit is contained in:
Vitaliy Olkhin 2024-11-06 13:52:14 +05:00
parent 2111a21f68
commit fa610bebe3
3 changed files with 44 additions and 33 deletions

View File

@ -32,6 +32,7 @@ local settings = {
use_real_entities = true, use_real_entities = true,
entity_update_interval = 0, entity_update_interval = 0,
enable_vertical_digilines_connectivity = true, enable_vertical_digilines_connectivity = true,
enable_debug = false,
} }
pipeworks.toggles = {} pipeworks.toggles = {}

View File

@ -349,53 +349,61 @@ function luaentity.get_objects_inside_radius(pos, radius)
end end
local move_entities_globalstep_part2 = function(dtime) local move_entities_globalstep_part2 = function(dtime)
local object = {}
if not luaentity.entities then if not luaentity.entities then
luaentity.entities = read_entities() luaentity.entities = read_entities()
end end
--minetest.log("action", "Dump: " .. dump(luaentity.entities)) --minetest.log("action", "Dump: " .. dump(luaentity.entities))
for _, entity in pairs(luaentity.entities) do for _, entity in pairs(luaentity.entities) do
--minetest.log("action", "entity " .. type(entity.owner)) --minetest.log("action", "entity " .. type(entity.owner))
--minetest.chat_send_all("online: " .. dump(entity.owner))
if entity.owner ~= nil then if entity.owner ~= nil then
local object = minetest.env:get_player_by_name(entity.owner) object = minetest.env:get_player_by_name(entity.owner)
if object then end
--minetest.chat_send_all("online: " .. dump(entity.owner))
--minetest.log("action", "pipeworks: активная передача по трубам игрок в сети: " .. entity.owner) if object or entity.owner ~= nil then
local master = entity._attached_entities_master --minetest.chat_send_all("online: " .. dump(entity.owner))
local master_def = master and entity._attached_entities[master] if pipeworks.enable_debug then
local master_entity = master_def and master_def.entity minetest.log("action", "pipeworks: активная передача по трубам игрок в сети: " .. entity.owner)
local master_entity_pos = master_entity and master_entity:get_pos() end
if master_entity_pos then
entity._pos = vector.subtract(master_entity_pos, master_def.offset) local master = entity._attached_entities_master
entity._velocity = master_entity:get_velocity() local master_def = master and entity._attached_entities[master]
entity._acceleration = master_entity:get_acceleration() local master_entity = master_def and master_def.entity
else local master_entity_pos = master_entity and master_entity:get_pos()
entity._velocity = entity._velocity or vector.new(0,0,0) if master_entity_pos then
entity._acceleration = entity._acceleration or vector.new(0,0,0) entity._pos = vector.subtract(master_entity_pos, master_def.offset)
entity._pos = vector.add(vector.add( entity._velocity = master_entity:get_velocity()
entity._pos, entity._acceleration = master_entity:get_acceleration()
vector.multiply(entity._velocity, dtime)), else
vector.multiply(entity._acceleration, 0.5 * dtime * dtime)) entity._velocity = entity._velocity or vector.new(0,0,0)
entity._velocity = vector.add( entity._acceleration = entity._acceleration or vector.new(0,0,0)
entity._velocity, entity._pos = vector.add(vector.add(
vector.multiply(entity._acceleration, dtime)) entity._pos,
end vector.multiply(entity._velocity, dtime)),
if master and not master_entity_pos then -- The entity has somehow been cleared vector.multiply(entity._acceleration, 0.5 * dtime * dtime))
if pipeworks.delete_item_on_clearobject then entity._velocity = vector.add(
entity:remove() entity._velocity,
else vector.multiply(entity._acceleration, dtime))
entity:_remove_attached(master) end
entity:_add_loaded() if master and not master_entity_pos then -- The entity has somehow been cleared
if entity.on_step then if pipeworks.delete_item_on_clearobject then
entity:on_step(dtime) entity:remove()
end
end
else else
entity:_remove_attached(master)
entity:_add_loaded() entity:_add_loaded()
if entity.on_step then if entity.on_step then
entity:on_step(dtime) entity:on_step(dtime)
end end
end end
else
entity:_add_loaded()
if entity.on_step then
entity:on_step(dtime)
end
end end
end end
end end
end end

View File

@ -100,3 +100,5 @@ pipeworks_log_teleport_tubes (Log Teleport Tubes) bool false
# Behavior of print() inside a lua tube. By default, this emits a message into actionstream. # Behavior of print() inside a lua tube. By default, this emits a message into actionstream.
# Set it to noop if you wish to disable that behavior. # Set it to noop if you wish to disable that behavior.
pipeworks_lua_tube_print_behavior (Behavior of print in Lua Tube) enum log log,noop pipeworks_lua_tube_print_behavior (Behavior of print in Lua Tube) enum log log,noop
pipeworks_enable_debug (Enable debug) bool false