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

Difference between revisions of "vtos"

From Quake Wiki

(Created page with "====Syntax:==== <code>string vtos(vector vec)</code> Converts a vector into a string to allow it to be printed to the console or displayed in a centerprint. ====Parameters:==...")
 
 
Line 1: Line 1:
====Syntax:====
+
''string'' '''vtos'''(''vector'' value)
<code>string vtos(vector vec)</code>
 
  
Converts a vector into a string to allow it to be printed to the console or displayed in a centerprint.
+
== Usage ==
====Parameters:====
+
Converts a vector to a string. Mainly used for printing messages.
:<code>vec</code> - The vector value to convert
 
====Returns:====
 
:Returns a string representation of the vector in the form <code>x y z</code>.
 
====Other Details:====
 
The string value returned by this function always points to the same area in memory. Running this function multiple times in the same frame will cause all strings to be set to the last vector converted.
 
  
 +
'''Warning:''' This does not return a unique string but a string shared across all instances of <code>vtos()</code>. Calling it again will change all currently stored references to the latest one. Storing the result has little value and it should only be called once per print function call.
 +
 +
=== Parameters ===
 +
*''value''
 +
:The vector to turn into a string.
 +
 +
=== Return ===
 +
The passed vector as a string.
 +
 +
== Example ==
 +
// Print the position of an entity while debugging
 +
dprint("Entity position: ");
 +
dprint(vtos(self.origin));
 +
dprint("\n");
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Latest revision as of 18:31, 31 July 2023

string vtos(vector value)

Usage[edit]

Converts a vector to a string. Mainly used for printing messages.

Warning: This does not return a unique string but a string shared across all instances of vtos(). Calling it again will change all currently stored references to the latest one. Storing the result has little value and it should only be called once per print function call.

Parameters[edit]

  • value
The vector to turn into a string.

Return[edit]

The passed vector as a string.

Example[edit]

// Print the position of an entity while debugging
dprint("Entity position: ");
dprint(vtos(self.origin));
dprint("\n");