zscript createThing/addThing/removeThing

Mon Jul 26, 2021 12:40 pm

I'm not sure if there's already a method to do this, but I couldn't find it. As far as I could find, there's currently no way to create a thing in ZScript without putting it onto the map, later adding said thing to the map, or removing them from the map without deleting them from memory. A lot of "object" based frameworks I've worked with typically work this way, where creating and removing a new class would go as so:

(Pseudo code)
//Creates the actor in memory only
//Usder can assign needed properties here
   Shells shelly = new Shells();

//Puts thing on map. User can set it's position afterwards.

//Takes it out of the map but does not remove from memory.
//Properties of this actor remain persistent until deleted or whatever

The exact wording of it isn't important, but I imagine it would be a lot easier for thing manipulation if on adding/removal, you wouldn't have to dedicate a separate class/struct to track it's info and have to rely on thing.destroy() and then spawning a whole new actor when the user needs to re-summon it, or rely on hacky tricks like teleporting the actor way outside the map to hide it.

Re: zscript createThing/addThing/removeThing

Mon Jul 26, 2021 2:28 pm

You cannot have a thinker that isn't on the map. The game code contains countless optimizations that assume that any thinker present is on the map. Remove that assumption and things will become a lot more complicated.