Quest

Holds information relating to a single quest. This information is very high level as it only contains information about if the quest has been completed, the name of the quest and a description. As such this means that it's up to each individual quest to store it's own information about steps required, rewards and events to itself.
Return to Index
new ( string quest_id )
__gc ( )
__eq ( am.quest rhs ) -> ( boolean )
start_quest ( ) -> ( boolean )
finish_quest ( ) -> ( boolean )
complete ( ) -> ( boolean )
complete ( boolean completed ) -> ( am.quest )
title ( ) -> ( string )
title ( string title ) -> ( am.quest )
description ( ) -> ( string )
description ( string description ) -> ( am.quest )
active_text ( ) -> ( string )
active_text ( string text ) -> ( am.quest )
on ( string event_name , function listener , table content = nil ) -> ( boolean )
off ( string event_name , function listener , table context = nil ) -> ( boolean )
has_event_listener ( string event_name ) -> ( boolean )
static add_quest ( am.quest quest ) -> ( boolean )
static remove_quest ( string quest_id ) -> ( boolean )
static find ( string quest_id ) -> ( am.quest )
attrs ( boolean create_table = false ) -> ( am.data_table )
attrs ( am.data_table attr_table ) -> ( am.quest )
new ( string quest_id )
Creates a new quest with the given quest id unless an existing quest with the same quest_id exists. If the quest was already existing then the 2nd return values is true.
Parameters:
string quest_id : The quest id for this quest.
Returns:
am.quest : The newly created quest or returns the quest that had the same quest_id.
boolean : True if the quest was newly created, false otherwise.
__gc ( )
Releases the reference on the internal quest.
__eq ( am.quest rhs ) -> ( boolean )
Compares if this quest is the same as the given quest object.
Parameters:
am.quest rhs : The other quest to compare with.
Returns:
boolean : True if they are the same quest object.
start_quest ( ) -> ( boolean )
Sets the flag that this quest has been started, if the quest has already been started this will return false. If the quest is started then the "startQuest" event will be fired.
Returns:
boolean : True if the quest was started, false indicates the quest has already been started.
finish_quest ( ) -> ( boolean )
Sets that the quest has been finished, this will return false is the quest has already been finished. If the quest is finished then the "finishQuest" event will be fired.
Returns:
boolean : True if the quest was finished, false indicates that the quest has alrady been finished.
complete ( ) -> ( boolean )
Returns true if the quest has been completed/finished.
Returns:
boolean : True if the quest has been completed/finished.
complete ( boolean completed ) -> ( am.quest )
Silently sets the quest completed/finished flag, this does not fire any events.
Parameters:
boolean completed : Sets if the quest has been completed/finished.
Returns:
am.quest : This
title ( ) -> ( string )
Returns the title of this quest.
Returns:
string : The quest title.
title ( string title ) -> ( am.quest )
Sets the title of this quest.
Parameters:
string title : The new quest title.
Returns:
am.quest : This
description ( ) -> ( string )
Returns the quest description.
Returns:
string : The quest description.
description ( string description ) -> ( am.quest )
Sets the quest description.
Parameters:
string description : The new quest description.
Returns:
am.quest : This
active_text ( ) -> ( string )
Returns the current active text for the quest. This can change over time as the player progresses through the quest.
Returns:
string : The current active text.
active_text ( string text ) -> ( am.quest )
Sets the active text, this should change to reflect how the player is progressing through the quest.
Parameters:
string text : The new active text.
Returns:
am.quest : This
on ( string event_name , function listener , table content = nil ) -> ( boolean )
Adds an event listener to this quest.
 quest = am.quest.new("testQuest")
 quest:on("startQuest", function(event)
     am.debug.log("Quest started")
     quest:finish_quest()
 end)
 quest:on("finishQuest", function(event)
     am.debug.log("Quest finished")
 end)
 quest:start_quest()
Parameters:
string event_name : 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_name , function listener , table context = nil ) -> ( boolean )
Removes an event listener from the quest. Currently the quest only has events which should only fire once, but if an event listener needs to changed before the event is fire it can be done.
Parameters:
string event_name : 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_name ) -> ( boolean )
Returns true when there is an event listener for the given event name.
Parameters:
string event_name : The event type to look up.
Returns:
boolean : True if there is any event listener that will be trigged by this event type.
static add_quest ( am.quest quest ) -> ( boolean )
Adds a quest to the game engine pool of quests. This allows for them to be looked up from anywhere using their quest id.
Parameters:
am.quest quest : The quest to add to the pool.
Returns:
boolean : True if the quest was successfully added.
static remove_quest ( string quest_id ) -> ( boolean )
Removes a quest from the quest pool using its quest id.
Parameters:
string quest_id : The quest id for the quest to remove.
Returns:
boolean : True if the quest was successfully removed.
static find ( string quest_id ) -> ( am.quest )
Returns the found quest from the quest pool.
Parameters:
string quest_id : The quest id of the quest to look up.
Returns:
am.quest : The found quest or nil.
attrs ( boolean create_table = false ) -> ( am.data_table )
Returns the quests attribute data table. By default if no attribute data table is present nil is returned unless true is passed as the first argument, then a data table is created if one is not present.
Parameters:
boolean create_table = false : Create a data table if one didn't exist.
Returns:
am.data_table : The data table on this quest.
attrs ( am.data_table attr_table ) -> ( am.quest )
Sets the data table on this quest, can be set to nil.
Parameters:
am.data_table attr_table : The data table to set on the quest.
Returns:
am.quest : This