What did you do?
I'm making a Warptorio-style mod where the player can teleport between surfaces. I've used surface.find_non_colliding_position to decide where to place the player and using player.teleport to teleport them there.
What happened?
The game freezes.
What did you expect to happen instead? It might be obvious to you, but do it anyway!
The player should teleport to a non-colliding-position, OR, nothing should happen (function returns false), OR, the game throws a script error due to some failure on my part.
Does it happen always, once, or sometimes?
Always.
This involves one mod not currently on the portal, so kindly see attached. To reproduce just start a new game with that mod (all dependencies are on the portal), click on the console, and try to teleport to ground. I'm sure this is caused by me doing something dumb, but I'd expect a coherent error in that case, rather than a game freeze.
[2.0.60] Game freezes when teleporting player to non colliding position
[2.0.60] Game freezes when teleporting player to non colliding position
- Attachments
-
- factorio-current.log
- (6.81 KiB) Downloaded 10 times
-
- warptorio-classic.zip
- (68.36 KiB) Downloaded 11 times
Re: [2.0.60] Game freezes when teleporting player to non colliding position
Seems to occur when the destination surface has no chunks. Generating a chunk ahead of time seems to resolve the issue.
Re: [2.0.60] Game freezes when teleporting player to non colliding position
What did you provide for the "radius" value?
If you want to get ahold of me I'm almost always on Discord.
Re: [2.0.60] Game freezes when teleporting player to non colliding position
0, which is an infinite search in theory, but in this case, the player is warping into the starting area of a default settings Nauvis, so there should be a ton of empty space immediately available in practice, and after generating the chunk, there is. I'd guess that the search neither generates chunks as part of the search, nor terminates when running out of generated chunks.
Re: [2.0.60] Game freezes when teleporting player to non colliding position
I see. Yes, in that case it will internally default to 500'000 which is functionally search the entire generatable map. It doesn't stop when finding un-generated chunks because it has no way to know if by searching more in a given direction it finds generated ones. In this case, everything is working correctly - but the outcome is not desired.
My only recommendation is don't do find-non-colliding-position searchs on chunks that haven't been generated yet.
My only recommendation is don't do find-non-colliding-position searchs on chunks that haven't been generated yet.
If you want to get ahold of me I'm almost always on Discord.
Re: [2.0.60] Game freezes when teleporting player to non colliding position
This has come up before with the same result. It would be really nice if the game could detect specifically when *zero* chunks are generated and throw an error before entering a near-infinite loop. Or simply disallow calling the non-colliding position function with an infinite search radius.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Re: [2.0.60] Game freezes when teleporting player to non colliding position
I'm dumb as bricks, the documentation explicitly calls out this case and I just brainfarted reading it. My apologies!