When attempting to teleport an Entity of type "character-corpse" or "corpse" the teleport api call will return true for a valid location but the entity is not teleported.
the api documentation states it should return false when it failed to teleport or the provided entity cant be teleported in general, however it seems to return true if the request was valid regardless if the entity can be teleported or not.
this is a consistent behaviour, every single time i call the function to teleport any entity of the above mentioned types it will write "Teleport Success: true" in the log despite the fact that the entity is not teleported and its coordinates remain the same as before the api call.
Apologies that the attached logfile is polluted by many other irrelevant outputs but searching for "Teleport Success: " will bring up the relevant lines and show that in the given example every tick its attempting to teleport from {x = 45.2421875, y = -32.5} to {x = 46.9375, y = -32.71875} which means the game doesnt accentually carry over the location which i attempt to teleport the entity to.
Performing an Api call a few lines later to show the results of the Mods on tick event handler
(easily found by searching for "Collision Handling Concluded" in the log file.)
also shows even before proceeding to the next tick already that the entity is still at its pre teleport api call coordinates and has not been teleported despite having received true from the teleport api call.
[2.0.47] Boolean returned by teleport does not represent Success.
-
- Inserter
- Posts: 24
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
[2.0.47] Boolean returned by teleport does not represent Success.
- Attachments
-
- factorio-current.log
- Log File of the output.
- (372.08 KiB) Downloaded 25 times
-
- Teleport.lua
- Function from a current project where i discovered the Bug.
- (678 Bytes) Downloaded 22 times
Re: [2.0.47] Boolean returned by teleport does not represent Success.
Please provide full reproduction steps or more accurately point at part of log that shows the failure to teleport the corpses.
I am not seeing any issues here:
A "Telepoerted "[LuaEntity]"" based on your script prints after a teleport, and you may notice the pretty print contains character-corpse at the expected position while the corpse printed below is at different position. Either those are 2 unrelated corpses or you have something else that teleports this corpse back.
I am not seeing any issues here:
Code: Select all
Teleport Success: true
Teleported "[LuaEntity: character-corpse at [gps=46.9,-32.7]]" from {x = 45.2421875, y = -32.5} to {x = 46.9375, y = -32.71875}
48.481 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8:
New Position: {x = 46.9375, y = -32.71875}
48.481 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8:
Collision Handling Concluded, temporary Data deleted. Remaining Collisions: {
["1"] = {
Corpse = "[LuaEntityPrototype: character-corpse (character-corpse)]",
Entity = "[LuaEntity: character-corpse at [gps=45.2,-32.5]]",
-
- Inserter
- Posts: 24
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: [2.0.47] Boolean returned by teleport does not represent Success.
The corpse is the same as it was during the test the only corpse (killed my player character) and the line reporting success is where it should end up which is "{x = 46.9375, y = -32.71875}" in this case but when checking the coordinates moments later it reports the corpse to be at the starting position before the teleport.boskid wrote: Sun May 18, 2025 11:24 am Please provide full reproduction steps or more accurately point at part of log that shows the failure to teleport the corpses.
I am not seeing any issues here:
A "Telepoerted "[LuaEntity]"" based on your script prints after a teleport, and you may notice the pretty print contains character-corpse at the expected position while the corpse printed below is at different position. Either those are 2 unrelated corpses or you have something else that teleports this corpse back.Code: Select all
Teleport Success: true Teleported "[LuaEntity: character-corpse at [gps=46.9,-32.7]]" from {x = 45.2421875, y = -32.5} to {x = 46.9375, y = -32.71875} 48.481 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8: New Position: {x = 46.9375, y = -32.71875} 48.481 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8: Collision Handling Concluded, temporary Data deleted. Remaining Collisions: { ["1"] = { Corpse = "[LuaEntityPrototype: character-corpse (character-corpse)]", Entity = "[LuaEntity: character-corpse at [gps=45.2,-32.5]]",
The Teleport function in the file i have attached is also the only location in the project which makes a teleport api call and during the test no other mod was enabled which would teleport it back, which would imply that either the game has moved it back inbetween the two times logging the position or that it didnt move it at all in the first place but was reporting the new position regardless.
Re: [2.0.47] Boolean returned by teleport does not represent Success.
So there is no reproduction i could take a look?
-- edit:
I did a quick check on a fresh save file:
and everything works fine.
-- edit:
I did a quick check on a fresh save file:
Code: Select all
/c
storage.corpse = game.surfaces.nauvis.create_entity{name="character-corpse", position={0,0}, force="player"}
script.on_event(defines.events.on_tick, function(e)
storage.corpse.teleport({ storage.corpse.position.x + 0.1, storage.corpse.position.y + 0.1 })
end)
-
- Inserter
- Posts: 24
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: [2.0.47] Boolean returned by teleport does not represent Success.
I have attached the Save file i used for the test and here https://www.dropbox.com/scl/fo/p1id5wuk ... xlieo&dl=0 is a copy of the mod which this function is a part of.boskid wrote: Sun May 18, 2025 1:32 pm So there is no reproduction i could take a look?
-- edit:
I did a quick check on a fresh save file:
and everything works fine.Code: Select all
/c storage.corpse = game.surfaces.nauvis.create_entity{name="character-corpse", position={0,0}, force="player"} script.on_event(defines.events.on_tick, function(e) storage.corpse.teleport({ storage.corpse.position.x + 0.1, storage.corpse.position.y + 0.1 }) end)
Which reliably always creates the situation i have described, what i do for the test is just step on the rails that are build and let the train drive to trigger the Mod to spring in to action.
Tho while i assumed its with the teleport function for obvious reasons im willing to admit that its entirely possible that the reason for my problems might be somewhere else that im not aware of.
- Attachments
-
- Momentum Modding.zip
- (2.45 MiB) Downloaded 6 times
Re: [2.0.47] Boolean returned by teleport does not represent Success.
Spacedestructor-Momentum-Fork_1.0.0/Scripts/EventHandlers/Tick.lua line 230 seems to be interfering.
Code: Select all
Teleport Success: true
Teleported "[LuaEntity: character-corpse at [gps=46.9,-32.7]]" from {x = 45.2421875, y = -32.5} to {x = 46.9375, y = -32.71875}
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8:
New Position: {x = 46.9375, y = -32.71875}
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/EventHandlers/Tick.lua:230: MWUAHAHA
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/EventHandlers/Tick.lua:230: MWUAHAHA
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/EventHandlers/Tick.lua:230: MWUAHAHA
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/EventHandlers/Tick.lua:230: MWUAHAHA
228.871 Script @__Spacedestructor-Momentum-Fork__/Scripts/Functions/Logging.lua:8:
Collision Handling Concluded, temporary Data deleted. Remaining Collisions: {
["1"] = {
Corpse = "[LuaEntityPrototype: character-corpse (character-corpse)]",
Entity = "[LuaEntity: character-corpse at [gps=45.2,-32.5]]",
-
- Inserter
- Posts: 24
- Joined: Sat Aug 19, 2017 6:06 pm
- Contact:
Re: [2.0.47] Boolean returned by teleport does not represent Success.
OH, i feel incredibly stupid right now.boskid wrote: Sun May 18, 2025 1:57 pm Spacedestructor-Momentum-Fork_1.0.0/Scripts/EventHandlers/Tick.lua line 230 seems to be interfering.
Im working to fix up a mess someone else made (hence why its a fork) and i totally forgot that the "HalfDistance" function also has a build in api call.
Appologies for wasting your time, i will continue my work and see if the issue persist after resolving the race condition that i didnt spot my self.