Custom Yarn Commands and Functions - AIessa/WhenLifeGivesYouLemons GitHub Wiki

The DialogUI script contains a number of Yarn (Yarn Spinner) Commands and Functions that you can use from within a Yarn script to affect other objects in the Unity scene or save and retrieve variable information.

Yarn Commands

Yarn Commands are defined in the following way:

Runner = GetComponent<DialogueRunner>();
Runner.AddCommandHandler(YarnCommandName, ClassMethodWithBehaviour);

The following custom commands were defined:

Manipulating dialogue visuals/audio:

  • SetSpeaker
  • SetNameKnown
  • NoSpeakerPic
  • NoSpeakerName
  • OpenChat
  • ChatMessage
  • CloseChat
  • HelperSays
  • SetBackground
  • RemoveBackground
  • BGFilter
  • AddXPCard
  • SetAudio

Manipulating game variables and scene objects:

  • AddXPCard
  • Energy
  • Relationship
  • ItemToInventory
  • LogEvent
  • AddNewTask
  • RemoveTask
  • AddCopingStrategy
  • TriggerScript

Yarn Functions

Yarn Commands are defined in the following way:

Runner = GetComponent<DialogueRunner>();
int number_of_input_arguments;
Runner.AddFunction(YarnFunctionName, number_of_input_arguments, delegate (Yarn.Value[] parameters)
        {
            //defining the behaviour
            return the_value_yarn_should_receive;
        });

The following custom functions were defined:

Retrieving simple variable information:

  • check_task
  • check_energy
  • check_relationship
  • check_card
  • check_event

Performing some computation and retrieving the result:

  • skill_check