GetLocalString

From NWN Lexicon
Jump to: navigation, search



GetLocalString(object, string)

Get the value of a string of characters stored on an object.

string GetLocalString(
    object oObject,
    string sVarName
);

Parameters

oObject

The object that stores the string of characters.

sVarName

The variable name of the data.


Description

Returns data contained inside the variable sVarName stored on the object oObject. oObject can be any object in the game world.

The string describing the variable can also be any string in theory but it is suggested that you avoid using the NW_* tags as they tend to be used within the game already. This function must be used in conjunction with its counterpart function SetLocalString, as this is the main way to adjust the values held in the variable sVarName. On error the function will return "", a blank string.



Remarks

To test the validness of the returned value, use this check (or similar):

if(GetLocalString(OBJECT_SELF, "STRING") != "")
{
// Is valid
}

This is most useful for setting what might be spoken (say, a password) a response to something or any use of an arbitrary string (such as if set on a creature, what they might randomly say when walking around).


Version

1.22

Example

// Will return the string stored in "Data"
void main()
{
    string a = GetLocalString(OBJECT_SELF,"Data");
    SendMessageToPC(GetFirstPC(),a);
}

See Also

functions: 

SetLocalString



 author: GoLeM, editor: Jasperre