Skip to content

Class: CPhraseScript

Script rules attached to a dialog phrase.

Source

C++ class CPhraseScript

Custom Constructor

CPhraseScript

Remarks

Phrase scripts are evaluated by the dialog engine against the current actor/NPC speakers. Info portion checks use the actor info registry.

Constructors

Constructor

ts
new CPhraseScript(): CPhraseScript;

Returns

CPhraseScript

Methods

AddAction()

ts
AddAction(function_name: string): void;

Run a script action after the phrase is spoken.

Parameters

ParameterTypeDescription
function_namestringScript function name.

Returns

void

Remarks

In active two-speaker dialogs the function receives (speaker, listener, dialog_id, phrase_id). In simpler dialog checks it receives (speaker, dialog_id).

Throws

If the function name cannot be resolved.


AddDisableInfo()

ts
AddDisableInfo(info_portion: string): void;

Disable an info portion when phrase actions run.

Parameters

ParameterTypeDescription
info_portionstringInfo portion id.

Returns

void

Remarks

Applied after the phrase is accepted and its actions run.


AddDontHasInfo()

ts
AddDontHasInfo(info_portion: string): void;

Require an info portion to be absent before the phrase is available.

Parameters

ParameterTypeDescription
info_portionstringInfo portion id.

Returns

void


AddGiveInfo()

ts
AddGiveInfo(info_portion: string): void;

Give an info portion when phrase actions run.

Parameters

ParameterTypeDescription
info_portionstringInfo portion id.

Returns

void

Remarks

Applied after the phrase is accepted and its actions run.


AddHasInfo()

ts
AddHasInfo(info_portion: string): void;

Require an info portion before the phrase is available.

Parameters

ParameterTypeDescription
info_portionstringInfo portion id.

Returns

void


AddPrecondition()

ts
AddPrecondition(function_name: string): void;

Add a script predicate checked before the phrase is available.

Parameters

ParameterTypeDescription
function_namestringScript function name.

Returns

void

Remarks

In active two-speaker dialogs the function receives (speaker, listener, dialog_id, phrase_id, next_phrase_id). It should return true when the phrase may be shown.

Throws

If the function name cannot be resolved.


SetScriptText()

ts
SetScriptText(function_name: string): void;

Use a script function to provide phrase text.

Parameters

ParameterTypeDescription
function_namestringScript function name.

Returns

void

Remarks

The function is called when the dialog asks for phrase text. Use it for text that depends on the current speaker or dialog state.

Throws

If the function name cannot be resolved.