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 API declarations
and the enum declarations, put them in one folder, and
add that folder to your Lua language server's libraries (in VS Code with the
Lua extension, Lua.workspace.library). They declare every public function,
method, callback and enum table, and mark older names as deprecated. Do not
execute these files or place them 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¶
- Start WololoLabs.
- Select Lua to open the Lua Scripts window.
- Select Features to see the script folder and every feature, yours marked Your script.
- Wait about one second for
helloto appear and switch on. A new script starts on. - Start or join a match.
- Check the Log Terminal for the
script loadedmessage. - Look for the label at the top-right of the screen.
Each script has a checkbox, a hotkey button and, once it declares options, an Options button, like the built-in features. See Lua features and your scripts. After you edit a script, select its Reload button. Use Reload all when you changed several scripts. If a script fails to load, it switches off: fix it, then switch it on again.
CAUTION: Every
.luafile inscriptsand its subfolders loads as a script, except options files named<script>.options.lua. 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¶
- Copy a basic example.
- Learn when callbacks run in Script callbacks.
- Read Write reliable scripts before you send commands.
- Find every available name in the API name index.