Difference between revisions of "Tutorial: String Variables 7"
Jump to navigation
Jump to search
imported>Odessa m |
imported>Gribbleshnibit8 m (Added NVSE and Tutorials Categories) |
||
Line 58: | Line 58: | ||
*[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]] |
Revision as of 12:10, 3 May 2015
This is the seventh article in a tutorial series on string variables.
Concatanating String Variables, or adding them up
Easy : +
let sv_stringvar := "String1" + "String2" printc "%z" sv_stringvar --> reads: 'String1String2' let sv_stringvar := Player.GetName + "'s chair" rChairRef.SetName $sv_stringvar --> reads 'Prudencia's chair' because that's my test char's name
Note: names are usually defined on the base form, and setting them will set them on the base form too.
When adding strings up, you may run into some limitations of passing variables into strings with format specifiers in the context of an addition:
let sv_stringvar := "First Part:" + playerref.GetName + ":" + "%.0f" iSomeInt let sv_stringvar := "First Part:" + "%n" rSomeForm
will make warnings pop up and not compile.
Luckily ToString($) is there, once again saving the day a lot of times:
let sv_stringvar := "First Part:" + playerref.GetName + ":" + $iSomeInt let sv_stringvar := "First Part:" + $rSomeForm
will be fine.
And if you can't do it in one line and can't use ToString, sometimes you just gotta do it in two or involve sv_construct again:
let sv_stringvar := sv_construct " is scratching %pp balls" rSomeRef ; had to add the sv_construct there to make the %pp specifier work let sv_stringvar := $rSomeRef + $sv_stringvar
And you can also get some traction out of the Sv_Insert function:
Sv_Insert "Some String" FormatSpecifierVars String_VarToInsertTheStringIn PositionToInsertAtInt let sv_stringvar := " balls must itch something fierce" sv_insert "%pp" rSomeForm sv_stringvar 0 ; or sv_insert "%pp" rSomeform sv_stringvar ; we want to insert it at the very first character of the stringvar's string, which is position 0 (like with formlists and arrays) ;if the position is 0 we can leave out that parameter, really
Tutorial part 8: Measuring and Searching