Difference between revisions of "String Variable"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
(Moved page to conventional capitalizaton/non plural)
 
imported>Pintocat
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{Template:Community_Wiki}}
String variables are added by NVSE 4. A string is simply some combination of text characters and exists widely in the vanilla game. A string variable allows you to store a string in a similar way to any other variable, and a wide range of functions allow powerful capabilities for them.
String variables are added by NVSE 4. A string is simply some combination of text characters and exists widely in the vanilla game. A string variable allows you to store a string in a similar way to any other variable, and a wide range of functions allow powerful capabilities for them.


String variables are very simple to use, provided you also use [[Let]] instead of [[Set]] and 'if [[Eval|eval]]' instead of simply 'if'. To appreciate the full range of possibilites available, a [[Tutorial: String Variables|tutorial]] is available.
String variables are very simple to use, provided you also use [[Let]] instead of <b>set .. to ..</b> and '[[Eval|if eval]]' instead of simply <b>if</b>. To appreciate the full range of possibilites available, a [[Tutorial: String Variables|tutorial]] is available.


==Simple Example==
==Simple Example==
Line 9: Line 13:
let my_string := "this is my string"
let my_string := "this is my string"


MessageEx my_string
let my_string += " and this is Sunny's name: " + $SunnyREF


if eval my_string == "this string"
if eval my_string == "this is my string and this is Sunny's name: Sunny Smiles"
   ; do something. Obviously this is false in this case.
   ; this will evaluate true
endif
endif
</pre>
</pre>


The [[ToString|ToString (shorthand: '$')]] function converts anything to a string. Vanilla and some old NVSE functions also require this to use a string_var instead of a string literal:
<pre>
Print my_string ; * new NVSE function
MessageEx $my_string ; * An old NVSE function
</pre>
If you want to use [[String Formatting]] rather than concatanation (+), you need to use [[Sv_Construct]]:
<pre>
<pre>
string_var my_string
string_var my_string
Line 21: Line 33:


let MyInt := 5
let MyInt := 5
let my_string := "the value of MyInt is %g", MyInt
let my_string := Sv_Construct "the value of MyInt is %g", MyInt
</pre>
</pre>


==See Also==
*[[Tutorial: String Variables]]
*[[String Formatting]]
*[[Let]]
*[[Eval]]
*[[ToString]]
*[[Sv_Construct]]
*[[Print]]
[[Category:String Variables]]
[[Category:String Variables]]
[[Category:NVSE]]
[[Category:NVSE]]

Latest revision as of 12:30, 7 May 2017


Please Note: The official wiki is no longer being maintained by the community[edit source]

The modding community for Fallout 3 and Fallout New Vegas has created its own wiki due to onerous and painful captcha requirements for every edit.

The active wiki contributors have moved to the new wiki -- for the most current information, visit:

http://geckwiki.com[edit source]

String variables are added by NVSE 4. A string is simply some combination of text characters and exists widely in the vanilla game. A string variable allows you to store a string in a similar way to any other variable, and a wide range of functions allow powerful capabilities for them.

String variables are very simple to use, provided you also use Let instead of set .. to .. and 'if eval' instead of simply if. To appreciate the full range of possibilites available, a tutorial is available.

Simple Example[edit | edit source]

string_var my_string

let my_string := "this is my string"

let my_string += " and this is Sunny's name: " + $SunnyREF

if eval my_string == "this is my string and this is Sunny's name: Sunny Smiles"
   ; this will evaluate true
endif

The ToString (shorthand: '$') function converts anything to a string. Vanilla and some old NVSE functions also require this to use a string_var instead of a string literal:

Print my_string ; * new NVSE function

MessageEx $my_string ; * An old NVSE function

If you want to use String Formatting rather than concatanation (+), you need to use Sv_Construct:

string_var my_string
int MyInt

let MyInt := 5
let my_string := Sv_Construct "the value of MyInt is %g", MyInt

See Also[edit | edit source]