Listener argument

Announcements, support questions, and discussion for Quest Machine.
Post Reply
GorkaGames
Posts: 178
Joined: Fri Sep 21, 2018 8:38 pm

Listener argument

Post by GorkaGames »

How do I get the argument on a listener? This is my custom condition script for Tracking message but I don¡t konw how to get the argument true / fasle:

public override void StartChecking(System.Action trueAction)
{
base.StartChecking(trueAction);
MessageSystem.AddListener(this, QuestMachineMessages.QuestTrackToggleChangedMessage, this.quest.id.ToString());
}

public void OnMessage(MessageArgs messageArgs)
{

if ((messageArgs.message == QuestMachineMessages.QuestTrackToggleChangedMessage) && (messageArgs.parameter == this.quest.id.ToString()) && messageArgs.)
{
SetTrue();
}
}
User avatar
Tony Li
Posts: 22143
Joined: Thu Jul 18, 2013 1:27 pm

Re: Listener argument

Post by Tony Li »

Hi,

Code: Select all

if ((messageArgs.message == QuestMachineMessages.QuestTrackToggleChangedMessage) && 
   (messageArgs.parameter == this.quest.id.ToString()) && 
   ((bool)messageArgs.firstValue == true))
Here is the API reference: MessageArgs.

MessageArgs contains:
  • (string) message: The message.
  • (string) parameter: The optional parameter that was sent with the message.
  • (object[]) values: An array of objects passed as additional arguments. They can be mixed types (bool, int, etc.).
  • (object) sender: The object that sent this message.
  • (object) target: The object that this message is intended for. May be null if it's a general message for everyone.
There are also aliases "firstValue" and "intValue". These are just aliases for:
  • firstValue = values[0]
  • intValue = (int)values[0]
Post Reply