Skip to content

Get started

Create one file first. This script shows a player name and match time. It uses the preferred global-function and object-method style.

Create the script

For editor completion, download the Lua declarations and configure your Lua language server to include them as a library. They currently cover group stop, tracked target/production orders and capability inspection. Do not execute this declaration file or place it in your script entry folder.

Start WololoLabs once. It creates this folder:

%APPDATA%\WololoLabs\scripts

Create hello.lua in that folder. Paste this script into the file:

local label = "Waiting for a match"

function Load()
    LogInfo("[hello] script loaded")
end

function Update()
    local player = GetAssignedPlayer()
    if player == nil then
        label = "Waiting for a match"
        return
    end

    label = string.format(
        "%s | %d seconds",
        player:GetPlayerName(),
        GetGameTime()
    )
end

function Render()
    RenderTopRightText(label, 12, 36, 16, Color("#FFFFFFFF"), true)
end

function Shutdown()
    LogInfo("[hello] script unloaded")
end

Load and check the script

  1. Start WololoLabs.
  2. Select Lua to open the Lua Scripts window.
  3. Select User scripts to see the script folder and discovered files.
  4. Wait about one second for hello.lua to load automatically.
  5. Start or join a match.
  6. Check the Log Terminal for the script loaded message.
  7. Look for the label at the top-right of the screen.

After you edit a loaded script, select its Reload button in the Loaded tab. Use Reload all when you changed several scripts. Use Rescan scripts after you fix a script that did not load.

CAUTION: Every .lua file in scripts and its subfolders loads as a script. Do not put helper files in this folder.

Use helper files

Use a module when a script needs require. Put the entry and its helpers under this folder instead:

%APPDATA%\WololoLabs\modules\sample-status\sample-status.main.lua
%APPDATA%\WololoLabs\modules\sample-status\format.lua

The entry file name must match its parent folder. For this example, both use sample-status.

In sample-status.main.lua, load the helper like this:

local format = require("format")

function Render()
    RenderTopRightText(format.label(), 12, 36)
end

In format.lua, return the values that the entry needs:

local M = {}

function M.label()
    return "Sample status"
end

return M

require("format") loads format.lua from the entry folder. A dotted name uses subfolders. For example, require("lib.format") loads lib/format.lua.

Use letters, digits, _, -, and . in a module name. Keep the name short. Do not use .. or an empty name segment.

Continue