Difference between revisions of "Sv Construct"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
m (clarified example)
imported>Odessa
 
Line 1: Line 1:
{{Function
{{Function
  |origin = NVSE
  |origin = NVSE
  |summary = Returns a string variable constructed from the specified string and up to 20 [[String Formatting|formatting]] arguments. If no formatting is required, this function is not necessary, as the [[Let]] command can be used to assign string variables.
  |summary = Returns a string variable constructed from the specified string and up to 20 [[String Formatting|formatting]] arguments.  
 
If no formatting is required, this function is not necessary, as the [[Let]] command can be used to assign string variables. Note that <b>Let</b> supports concatanation and the [[ToString|ToString($)]] function which can usually achieve the same result as formatting.


  |name = Sv_Construct
  |name = Sv_Construct
Line 14: Line 16:
==Example==
==Example==
<pre>
<pre>
string_var simple_string
string_var my_string
string_var my_string
int iValue
int iValue
ref rActor
ref rActor


let simple_string := "Just plain text" ; * Sv_Construct is not necessary here
; Used to construct a formatted string:


let my_string := Sv_Construct "iValue equals %g and rActor's name is %n", iValue, rActor
let my_string := Sv_Construct "iValue equals %g and rActor's name is %n", iValue, rActor
</pre>
Typically you can skip Sv_Construct and use concatanation with [[ToString|ToString($)]] instead of formatting, if you prefer:
<pre>
let my_string := "iValue equals " + $iValue + " and rActor's name is " + $rActor
</pre>
</pre>
==See Also==
==See Also==

Latest revision as of 09:24, 28 July 2014

< [[::Category:Functions|Category:Functions]]

A function added by the New Vegas Script Extender.

Description

Returns a string variable constructed from the specified string and up to 20 formatting arguments.

If no formatting is required, this function is not necessary, as the Let command can be used to assign string variables. Note that Let supports concatanation and the ToString($) function which can usually achieve the same result as formatting.

Syntax

[help]
(string_var) Sv_Construct Literal:string Formatting

Example

string_var my_string
int iValue
ref rActor

; Used to construct a formatted string:

let my_string := Sv_Construct "iValue equals %g and rActor's name is %n", iValue, rActor

Typically you can skip Sv_Construct and use concatanation with ToString($) instead of formatting, if you prefer:

let my_string := "iValue equals " + $iValue + " and rActor's name is " + $rActor

See Also