Getting Started
Five minutes from empty file to a script that reads your health and acts on it.
Your first script
Open the Lua tab, press New…, name it hello,
and open the editor. Type:
print('Hello, Sosaria!')
Messages.Overhead('Hello!', 68)
Press Play. print goes to the IDE console;
Messages.Overhead appears above your head in game (68 is a
hue — green).
Reading the world
Game state comes from module functions and object tables. Find things, then read their fields:
-- your own vitals are properties on Player
if Player.Hits < Player.HitsMax * 0.5 then
Messages.Print('Half health!', 33)
end
-- find an item by graphic (0x-hex works for all ids/serials)
local bandages = Items.FindByType(0xE21)
if bandages then
Messages.Print('Bandages: ' .. bandages.Amount)
end
Finders return a Lua table (see
Objects & Fields) or nil —
always check before using the result.
Doing things
local bandages = Items.FindByType(0xE21)
if bandages then
Player.UseObject(bandages.Serial) -- double-click the bandages
Targeting.WaitForTarget(2000) -- wait up to 2s for the cursor
Targeting.Self() -- target yourself
end Pause is the heartbeat
Scripts run in their own loop — the game does not wait for you. After any action that needs server time, give it that time:
while true do
if Player.Hits < Player.HitsMax then
-- heal ...
end
Pause(500) -- REQUIRED: yields to the game, pumps UI callbacks
end
A loop without Pause starves everything else — the engine
stops such scripts. Pause(ms) is also what keeps
script UI windows responsive.
Organizing code
Import('helpers') loads another file from
Data\LuaScripts (the sandboxed replacement for
require — file name only, no paths).
ExecuteMacro('bank run') plays a classic Razor macro from a
script, so the two systems combine freely. Stop any running script with
StopScript() or the Stop button.