Skip to content

Development

Kara edited this page Mar 24, 2024 · 6 revisions

Setup

  1. Clone the repo somewhere: git clone https://github.com/karashiiro/TextToTalk; cd TextToTalk/src
  2. Clone any submodules within the repo: git submodule update --init --recursive
  3. Try building the repo from the command line: dotnet restore; dotnet build

If the build fails due to Dalamud not being found, make sure Dalamud is installed on your system. If you plan to build against your own Dalamud build output, set the DALAMUD_DEV environment variable to the path of your Dalamud build output directory. On Linux, ensure your DALAMUD_HOME variable is set to your installation's Dalamud directory. At the time of writing, the build system's Dalamud path detection is configured here.

If the build fails due to ConfigComponents not being found, make sure you're using the latest version of the .NET SDK. ConfigComponents uses Roslyn source generators, which may fail if the latest version of the SDK is not installed.

  1. Find the built plugin at src/TextToTalk/bin/Debug/net8.0/TextToTalk.dll - this should be loaded as a dev plugin in Dalamud.

Once the plugin successfully builds from the command line, the solution file can be opened in your IDE of choice, and additional issues may be debugged from there.

Text event logging

In debug builds, all text events that make it to the plugin's event processing pipeline (some events may be filtered out before reaching the pipeline, depending on your settings) are logged to a LiteDB database called log.db, in the plugin's configuration directory. This file can be opened with LiteDB.Studio and queried with SQL.

The LiteDB documentation has a useful list of supported functions here.

Note that the database uses a write-ahead log, and does not update the main database until the database is checkpointed - either when the WAL reaches a large enough size or when the plugin unloads. For this reason, it's best to only connect to the database after unloading the plugin. LiteDB.Studio can connect to the database while the plugin is also using the database, but note that plugin reloads may break and require restarting the game.

The best LiteDB.Studio settings for avoiding issues are:

  • Connection mode: Direct
  • Parameters:
    • Read only: Checked

Querying text events

Text events are stored in the event table, which can be explored with the query SELECT Event FROM event;. Each entry is a TextEvent instance, which contains all event parameters and information about the event type. If there aren't any events in the table yet, try typing some chat messages and then reloading the plugin (make sure you're using a debug build!).

For a more useful view, try the following query:

SELECT Timestamp,
       LAST(SPLIT(FIRST(SPLIT(Event._type, ', ')), '.')) AS Type,
       Event.Source AS Source,
       Event.ChatType AS ChatType,
       COALESCE(Event.Speaker, Event.SpeakerName) AS Speaker,
       Event.Text AS Text,
       Event
FROM event
ORDER BY Timestamp DESC;

image

Other useful queries will be added to the scripts/db folder over time.