I have completed my Safe Zone extension for Game Maker, and made it available.
Altogether, here’s what we now have:
SafeZone.gmk – the original proof of concept, which creates a non-wrapping, square safe zone around the protected object.
SafeZone2.gmk – improved proof of concept, which creates a circular safe zone which wraps around the protected object.
SafeZone5.gmk – Further refined, now the function incorporates parameters which control whether the wrap applies in the vertical or horizontal directions, or both, or neither.
SZ5.gml – the raw .gml of the script code written for SafeZone5.gmk
SafeZone_1_0.gex – The Safe Zone extension, v.1.0, based on the SafeZone5 code.
SZ_GEX_demo.gmk – a demo project which incorporates the .gex rather than scripts.
This extension could use further refinement, as it assumes that literally anywhere else in the room is safe to place the new instance. If you have solid objects in your room, or multiple other objects that you do not want to collide with upon spawning the new object, this obviously will not hold true. But for certain types of games, such as single-player free-flight games, this should be quite useful.