Skip to content
Adam Sechrest edited this page Jul 9, 2022 · 23 revisions

(Work in Progress)

Introduction

The concept of triggers is that Lich will respond automatically to certain game output without the need to run a separate script. Historically, the ability to set triggers is a function of the Front End being used. Lich-based triggers are front-end agnostic and built within Lich itself. Thus, they can be used across and between front ends. Simple triggers have a fairly low barrier to entry for users, and more advanced uses can allow some complex handling without writing a dedicated script. Further, triggers can supplement the use of curated or custom Lich scripts. At some point, though, the complexity of an action calls for writing a dedicated script.

Underlying Code Structure

Lich's triggers are defined by the user in a yaml file along with the desired trigger responses. Triggers are then monitored for and acted upon with a persistent companion script called trigger-watcher. Fundamentally, Lich's triggers use class Flags which is defined in the events script and at a basic level monitor for user-defined game output. In order for Lich triggers to work, triggers must be defined properly in the yaml, and both the events and trigger-watcher script must stay running.

Simple Triggers and Responses

The structure of each trigger is as follows:

  • The name of this specific trigger. This is arbitrary -- name it what you want.
  • Beneath that and indented, a section called triggers:. This represents the game output you want the trigger to look for and then take action.
  • Beneath that and indented, a section called response:. When Lich sees the output you defined in the triggers section, it will process these trigger responses.

Let's look at an extremely simple trigger.

# LICH TRIGGERS
# Yaml for Lich-based triggers

wave_hello:
  triggers:
    - Bobafett just arrived
  responses:
    - wave Bobafett

This trigger recognizes when a character named Bobafett enters the room, and it waves to them. What's happening behind the scenes is that Lich is watching all game output lines for Bobafett just arrived. When it sees that, it takes the action you've defined in responses and it will send wave Bobafett as a game input command.

Some Finer Details

Within a single trigger name, you can specify multiple triggers and multiple responses. Here are some simple examples:

# LICH TRIGGERS
# Yaml for Lich-based triggers

wave_hello:
  triggers:
    - Bobafett just arrived
    - Hansolo just arrived
  responses:
    - wave

Here we've specified two different triggers, and modified our response slightly. If Lich sees game output of either Bobafett just arrived OR Hansolo just arrived, it will trigger a response of game input wave.

# LICH TRIGGERS
# Yaml for Lich-based triggers

wave_hello:
  triggers:
    - Bobafett just arrived
  responses:
    - wave Bobafett
    - kick Bobafett

Here we've specified a single trigger but two responses. If Lich sees Bobafett enter the room, it will send the two responses as game commands one right after the other: wave Bobafett and kick Bobafett.

Trigger Commands

A set of trigger commands is provided for use by the user. These commands tell Lich treat trigger responses in various ways.

Clone this wiki locally