Skip to content

0.43.05-r3

Compare
Choose a tag to compare
@BenLubar BenLubar released this 23 Nov 22:10
e0c73dd

Installation instructions

New Plugin

Introducing weblegends! It's an enhanced version of legends mode that you can use while playing Dwarf Fortress or watching DF-AI play for you!

  • References to historical figures, civilizations, sites, governments, regions, and artifacts automatically link to their respective pages.
  • No export needed - weblegends will automatically load data from the game as it is requested.
  • Long lists are automatically split across multiple pages to reduce load times.

Plugin API

Plugins for a plugin? That's right, you can write weblegends plugins, which are plugins for a DFHack plugin, which is a plugin for Dwarf Fortress.

  • Include weblegends-plugin.h in your plugin. The version of weblegends-plugin.h in this release of weblegends is guaranteed to work in all future releases, but new features may be added in future versions of weblegends-plugin.h.
  • For this initial version of weblegends, three functions are available in the plugin API:
    • add_weblegends_handler takes a prefix (ex. "df-ai"), a handler (described below), and an optional label (ex. "Artificial Intelligence"). It returns true if the handler was added, or false if the handler was not added, either because another handler already existed with the same prefix, or because the prefix was invalid (prefixes must not be empty or contain /).
    • remove_weblegends_handler takes a prefix (ex. "df-ai") and removes the handler associated with it. You should call remove_weblegends_handler if your plugin is unloading to avoid crashes from attempting to access your (no longer available) handler function.
    • weblegends_describe_event takes an output stream and a Dwarf Fortress history_event and writes a description of the event to the output stream. If weblegends is loaded, the description will automatically link to related pages in weblegends.
  • Handlers are functions that take an output stream and a suffix of the address (ex. "/report"). They return true if the page was found, and return false if the page was not found. Handlers should write a full HTML page encoded in CP437 and include a <base href=".."/> pointing to the root directory of weblegends.
    • CP437 is important, because \n will appear as a black filled square with a white circle in it to users.
    • For pages with no slashes in the suffix, omit the <base/> element. For pages with one slash, use <base href=".."/>, for two slashes use <base href="../.."/>, and so on.
    • See df-ai's weblegends handler for an example.