Sv Count
A function added by the New Vegas Script Extender.
Contents
Description
Returns the number of occurrences of some sub string within a string variable. By default it is case insensitive, but an optional flag is available to change this.
The first argument is a string, which may have optional formatting information thereafter. This is what you want to count.
The second argument (ignoring the optional formatting) is a string variable within which to search for the first string.
There are three optional int arguments at the very end: a start position and end position, which allow searching of a substring of the string_var, and finally, a boolean flag to enable case sensitivity.
Syntax
(int) Sv_Count toFind:string 20xOptional:formatting within:string_var startPos:int numChars:int caseSensitiveFlag:int
Example
string_var my_message let my_message := "The owls are not what they seem" Sv_Count "owls", my_message ; will return 1 Sv_Count "foxes", my_message ; will return 0 Sv_Count "the", my_message ; will return 2: found in words 'The' and 'they'
Another example, maybe you want to be able to specify complex script instructions as a single string?
string_var my_instructions ref rActor if eval (Sv_Count "sunny smiles", my_instructions) let rActor := SunnyREF else let rActor := PlayerREF endif if eval (Sv_Count "kill", my_instructions) > 2 ; kill actor if I get asked 3 times rActor.Kill elseif eval (Sv_Count "move", my_instruction) ; move actor if I get asked one or more times. rActor.MoveTo PlayerREF endif