July 20, 2017

Bundled Libraries

Standard Lua Libraries

The following standard Lua libraries are included:

  • basic functions
    • Loading of binary lua files is not supported and search paths are limited to the module folder.
  • package
    • Binary lua modules and native C libraries are not supported
    • Search paths are limited to the module folder and bundled library path
  • bit32
  • table
  • string
  • math

Other Libraries

The following libraries are bundled and can be required:

  • cgilua/lp – Implementation of LuaPages to allow HTML pages to be built dynamically (any pages served will be subsequently sanitised).

LuaPages output

Certain calls made to the game via the mod API are capable of generating HTML output for messages and help dialogs that can be displayed by the client. The LuaPages library can be used as a convenient way to generate these pages from template files.

For security reasons, the HTML you can display is limited to the contents of the <body> section, and only the following tags and attributes are permitted:

  • Basic formatting tags <h1> - <h6>, <p>, <div>,<blockquote>,<pre>,<b>,<i>,<b>,<em>
  • Unordered and ordered list tags, definition lists, simple tables
  • <a> anchors, with the href attribute only
  • id and class attributes
  • <img> tags with src attribute
  • <form> (post method, with action set to an allowed URL)
  • <input> (type="hidden", name and value attributes only)

The URLs that can be returned are restricted to

Files served from the lp/ folder have access to the following globals

  • url_constants.static_content_path – path to the mod static/ folder
  • is_game_running – true if the game is running, false if the content is displayed in the lobby before starting the game

In addition, files served as part of in-game dialogs and contextual help also have access to

  • url_constants.game_endpoint_path – path to the game REST endpoint for submitting the results of any message dialogs

The above list of allowed HTML features may be extended in future.