Difference between revisions of "Tutorial: String Variables 6"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
m
imported>Gribbleshnibit8
m (Added NVSE and Tutorials Categories)
 
Line 56: Line 56:
*[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ This tutorial was originally adapted with permission from this forum post]
*[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ This tutorial was originally adapted with permission from this forum post]


[[Category:NVSE]]
[[Category:String Variables]]
[[Category:String Variables]]
[[Category:Tutorials]]

Latest revision as of 12:09, 3 May 2015

This is the sixth article in a tutorial series on string variables.

Passing String Variables as parameters: ToString ($)[edit | edit source]

If a vanilla or NVSE function takes one or more formatted strings as parameters:

DebugPrint "I'm a string"
MessageEX "I'm a string"
SetModelPathEX "Clutter\Junk\WhetStone.NIF"
NX_SetEVFl "some nx key string" someFloat
NX_SetEVSt "some nx key string" "some string value"

you can force them to take a string variable as parameter instead with the ToString function, in short: $

DebugPrint $sv_stringvar
MessageEX $sv_stringvar
SetModelPathEX $sv_stringvar
NX_SetEVFl $sv_keystringvar someFloat
NX_SetEVSt $sv_keystringvar $sv_valuestringvar

There are a few functions, especially fallout-specific ones and ones that are injected with NVSE plugins like MCM, that may not seem to work with ToString + string var that way - this is because they probably haven't been prepped for that. If you think this is the case in your script, try using the script compiler override, which should force it.


The ToString function can also return a string representation of numbers and forms, ie pass them to a string:

It will return the name of a form if the form has a name:

let rRef := DocMitchellRef
let sv_name := $rRef
printc "%z" sv_name
  --> displays 'Doc Mitchell'

Or its hex FormID if it doesn't:

let rRef := BlackBoardMarker
let sv_name := $rRef
printc "%z" sv_name
  --> displays '00002FCC'

Numbers:

let iInt := 32
let sv_name := $iInt
printc "%z" sv_name
  --> displays '32'

Tutorial part 7: Concatanating string vars, or adding them up

External Links[edit | edit source]