Dialogue

The dialogue class represents a single dialogue segment. Each segment has a wall of text, a title, a subject, an unlock flag and an action. If a dialogue is locked, it can only be unlocked by subject. Once an unlocked dialogue with a given subject is activated, all locked dialogues with the same subject are unlocked.
Return to Index
new ( string dialogue_id , string text , string title = "" , string subject = "" , string unlock_flag = "none" , string action = "none" )
__gc ( )
__eq ( am.dialogue rhs ) -> ( boolean )
text ( ) -> ( string )
text ( string text ) -> ( am.dialogue )
title ( ) -> ( string )
title ( string title ) -> ( am.dialogue )
id ( ) -> ( string )
id ( string id ) -> ( am.dialogue )
subject ( ) -> ( string )
subject ( string subject ) -> ( am.dialogue )
unlock ( ) -> ( string )
unlock ( string flag ) -> ( am.dialogue )
action ( ) -> ( string )
action ( string action ) -> ( am.dialogue )
static add_dialogue ( am.dialogue dialogue ) -> ( boolean )
static remove_dialogue ( string dialogue_id ) -> ( boolean )
static remove_all_dialogue ( ) -> ( )
static dialogue ( string dialogue_id ) -> ( am.dialogue )
on ( string event_type , function listener , table content = nil ) -> ( boolean )
off ( string event_type , function listener , table context = nil ) -> ( boolean )
has_event_listener ( string event_type ) -> ( boolean )
new ( string dialogue_id , string text , string title = "" , string subject = "" , string unlock_flag = "none" , string action = "none" )
Creates a new dialogue.
Parameters:
string dialogue_id : The unique id for this dialogue.
string text : The dialogue text.
string title = "" : The title for this dialogue.
string subject = "" : The subject of this dialogue.
string unlock_flag = "none" : Either "none" or "locked".
string action = "none" : Either "none", "shop" or "close".
__gc ( )
The dialogue won't be destroyed until it is removed from the game engine.
__eq ( am.dialogue rhs ) -> ( boolean )
Compares this dialogue with another dialogue object.
Parameters:
am.dialogue rhs : The other dialogue to compare with.
Returns:
boolean : True if they are the same dialogue object.
text ( ) -> ( string )
Returns the raw dialogue text.
Returns:
string : The raw dialogue text.
text ( string text ) -> ( am.dialogue )
Sets the raw dialogue text.
Parameters:
string text : The new dialogue text.
Returns:
am.dialogue : This
title ( ) -> ( string )
Returns the title for this dialogue.
Returns:
string : The title for this dialogue.
title ( string title ) -> ( am.dialogue )
Sets the dialogue title.
Parameters:
string title : The new dialogue title.
Returns:
am.dialogue : This
id ( ) -> ( string )
Returns the unique id for this dialogue.
Returns:
string : This dialogues unique id.
id ( string id ) -> ( am.dialogue )
Sets the dialogues id.
Parameters:
string id : The dialogue's new id.
Returns:
am.dialogue : This
subject ( ) -> ( string )
Returns the subject title for this dialogue, this can be an empty string.
Returns:
string : The subject title.
subject ( string subject ) -> ( am.dialogue )
Sets the subject title for this dialogue. The subject can determine if a dialogue option is unlocked, as once any dialogue with a given subject is unlocked, all dialogue's with the same subject are unlocked.
Parameters:
string subject : The subject title for this dialogue.
Returns:
am.dialogue : This
unlock ( ) -> ( string )
Returns the dialogue unlock flag. This determines if the dialogue if locked by subject from the start or if it is always unlocked.
Returns:
string : Either "none" or "locked"
unlock ( string flag ) -> ( am.dialogue )
Sets how the dialogue is unlocked, it is either locked by subject or always unlocked.
Parameters:
string flag : Either "none" or "locked"
Returns:
am.dialogue : This
action ( ) -> ( string )
Returns the specific action associated with this dialogue.
Returns:
string : Either "none", "shop" or "close"
action ( string action ) -> ( am.dialogue )
Sets the dialogue action, these trigger special events when the dialogue is used.
Parameters:
string action : Either "none", "shop" or "close"
Returns:
am.dialogue : This
static add_dialogue ( am.dialogue dialogue ) -> ( boolean )
Adds a dialogue to the game engines dialogue pool. Dialogues in the dialogue pool can be automatically accessed by the dialogue system.
Parameters:
am.dialogue dialogue : The dialogue to add.
Returns:
boolean : True if the dialogue was successfully added.
static remove_dialogue ( string dialogue_id ) -> ( boolean )
Removes a dialogue from the game engines dialogue pool.
Parameters:
string dialogue_id : The dialogue id to remove.
Returns:
boolean : True if the dialogue was successfully removed.
static remove_all_dialogue ( ) -> ( )
Removes all dialogue from the game engine.
static dialogue ( string dialogue_id ) -> ( am.dialogue )
Finds a dialogue in the dialogue pool with the given dialogue id.
Parameters:
string dialogue_id : The dialogue id to search for.
Returns:
am.dialogue : The found dialogue or nil.
on ( string event_type , function listener , table content = nil ) -> ( boolean )
Adds an event listener for an event fired on this character. eg:
 character:on("talkTo", function(event)
     am_log("Character talked to")
 end)
Parameters:
string event_type : The event type or name to trigger on
function listener : The function to call when the event is fired.
table content = nil : An option context for the listener to be called with.
Returns:
boolean : True if the event was added successfully.
off ( string event_type , function listener , table context = nil ) -> ( boolean )
Removes an event listener from this character. eg:
 function talkToOnce(event)
     am_log("Character talked to once")
     character:off("talkTo", talkToOnce)
 end
 character:on("talkTo", talkToOnce)
Parameters:
string event_type : The event type the listener was listening for.
function listener : The listener function to remove.
table context = nil : The context which the listener was going to be called with, this is only optional if the listener was added with no context.
Returns:
boolean : True if the event listener was successfully removed.
has_event_listener ( string event_type ) -> ( boolean )
Returns true when there is an event listener for the given event_type.
Parameters:
string event_type : The event type to look up.
Returns:
boolean : True if there is any event listener that will be trigged by this event type.