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

Difference between revisions of "objerror"

From Quake Wiki

m (Example)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
====Syntax:====
+
''void'' '''objerror'''(''string'' message)
<code>void objerror(string message)</code>
 
  
Removes self and displays an error message.
+
== Usage ==
====Parameters:====
+
Throws an error related to the current '''self''' entity. Information about this entity is dumped in the console. This entity is also removed and execution of its code will stop. This should be used for culling improperly set up entities or ones that enter invalid states.
:<code>message</code> - The error message to display
 
====Returns:====
 
:void
 
  
 +
=== Parameters ===
 +
*''message''
 +
:The message to display alongside the entity information dump in the console.
 +
 +
== Example ==
 +
// This entity assumes it will have a valid target id
 +
// If not, it removes itself with an error
 +
void func_my_entity()
 +
{
 +
    if (!self.target)
 +
        objerror("func_my_entity was not given a valid target id\n");
 +
 +
    // ...
 +
}
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 12:13, 31 July 2023

void objerror(string message)

Usage[edit]

Throws an error related to the current self entity. Information about this entity is dumped in the console. This entity is also removed and execution of its code will stop. This should be used for culling improperly set up entities or ones that enter invalid states.

Parameters[edit]

  • message
The message to display alongside the entity information dump in the console.

Example[edit]

// This entity assumes it will have a valid target id
// If not, it removes itself with an error
void func_my_entity()
{
    if (!self.target)
        objerror("func_my_entity was not given a valid target id\n");

    // ...
}