Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Difference between revisions of "spawn (function)"

From Quake Wiki

 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
====Syntax:====
+
''entity'' '''spawn'''()
<code>entity spawn()</code>
 
  
Used to create a new entity
+
== Usage ==
====Parameters:====
+
Creates a new default entity. Note that if you're spawning an entity that relies on precached sounds and models, one entity of that type must be spawned at map load or their sounds and models precached elsewhere (the server itself, another entity type, etc.).
:None
 
====Returns:====
 
:A new entity
 
  
 +
=== Return ===
 +
The newly created entity.
 +
 +
== Example ==
 +
// Creates an Ogre
 +
entity ogre = spawn();
 +
ogre.classname = "monster_ogre";
 +
 +
entity curSelf = self;
 +
self = ogre;
 +
monster_ogre();
 +
self = curSelf;
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:32, 31 July 2023

entity spawn()

Usage[edit]

Creates a new default entity. Note that if you're spawning an entity that relies on precached sounds and models, one entity of that type must be spawned at map load or their sounds and models precached elsewhere (the server itself, another entity type, etc.).

Return[edit]

The newly created entity.

Example[edit]

// Creates an Ogre
entity ogre = spawn();
ogre.classname = "monster_ogre";

entity curSelf = self;
self = ogre;
monster_ogre();
self = curSelf;