mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
52 lines
1.7 KiB
Plaintext
52 lines
1.7 KiB
Plaintext
|
|
trigger OnHearSpeech(obj_id speaker, string text)
|
|
{
|
|
if (!text.equals("scriptvartest" ))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
obj_id target = getLookAtTarget( speaker );
|
|
if ( target == null )
|
|
{
|
|
debugSpeakMsg( self, "Look-at something and then say scriptvartest" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else if ( target == self )
|
|
{
|
|
debugSpeakMsg( self, "I know I can set scriptvars on myself. Look at something else" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
//Take an int value out, increment it, and put it back in:
|
|
deltadictionary targetScriptVars = target.getScriptVars();
|
|
int testScriptVar = targetScriptVars.getInt( "scriptvartest" );
|
|
debugSpeakMsg( self, "spriptvar test value on " + target + " is " + testScriptVar );
|
|
testScriptVar++;
|
|
targetScriptVars.put( "scriptvartest", testScriptVar );
|
|
|
|
//Get the scriptVars again and see what the value is:
|
|
deltadictionary newTargetScriptVars = target.getScriptVars();
|
|
int newTestScriptVar = newTargetScriptVars.getInt( "scriptvartest" );
|
|
debugSpeakMsg( self, "Immediately: spriptvar test value on " + target + " is " + newTestScriptVar );
|
|
|
|
//do a callback to see what the value is 2 seconds from now:
|
|
dictionary parms = new dictionary();
|
|
parms.put( "target", target );
|
|
messageTo( self, "handleRecheck", parms, 2, false );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleRecheck()
|
|
{
|
|
obj_id target = params.getObjId( "target" );
|
|
if ( target == null || target == obj_id.NULL_ID )
|
|
{
|
|
debugSpeakMsg( self, "target is fuxed" );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
deltadictionary targetScriptVars = target.getScriptVars();
|
|
int testScriptVar = targetScriptVars.getInt( "scriptvartest" );
|
|
debugSpeakMsg( self, "After Call Back: spriptvar test value on " + target + " is " + testScriptVar );
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|