zscript createThing/addThing/removeThing

Moderator: GZDoom Developers

User avatar
kevansevans
Spotlight Team
Posts: 429
Joined: Tue Oct 05, 2010 12:04 am
Graphics Processor: nVidia with Vulkan support

zscript createThing/addThing/removeThing

Post by kevansevans »

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)

Code: Select all

//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.
   map.addChild(shelly);

//Takes it out of the map but does not remove from memory.
//Properties of this actor remain persistent until deleted or whatever
   map.removeChild(shelly);
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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49183
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: zscript createThing/addThing/removeThing

Post by Graf Zahl »

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.

Return to “Closed Feature Suggestions [GZDoom]”