UOSAGAS Scripting

API Reference

All 92 functions across 12 modules. Object fields (what a found item or mobile contains) are on the Objects & Fields page; the window and control methods of the UI live on the Script UI page.

This list is generated from the engine itself: the inventory comes from the real registrations, so if a function is here, it exists — and if it is missing, it does not.

Core & Flow

ExecuteMacro

ExecuteMacro(macroName)

Looks up a recorded Razor macro (case-insensitive name match) and plays it. Returns false with a warning if no macro with that name exists. Returns: true if the macro was found and started, false otherwise.

ParameterMeaning
macroName Name of the Razor macro to play.
Example
if not ExecuteMacro('BankRun') then
    Messages.Warning('Macro missing!')
end

Import

Import(scriptName)

The argument must be a plain file name (no paths, no '..'); the '.lua' extension is added automatically. The imported script runs in the same environment, so its global functions and variables become available. Returns the imported script's first return value, if any. Returns: The imported script's return value, or nothing.

ParameterMeaning
scriptName File name of a script in the Lua scripts folder, e.g. 'helpers'.
Example
-- loads helpers.lua from the same scripts folder
local lib = Import('helpers')

Pause

Pause(milliseconds)

While paused, the engine automatically pumps Script-UI callbacks and bindings in 50 ms slices, so button clicks and bound labels keep working during the wait. Use this between game actions instead of busy loops.

ParameterMeaning
milliseconds How long to wait, in milliseconds.
Example
Player.Say('Starting...')
Pause(1000)
Player.Say('One second later.')

print

print(...)

Accepts any number of arguments (strings, numbers, booleans, tables); they are joined with tabs. Handy for quick debugging.

ParameterMeaning
... optional One or more values to print.
Example
print('Hits:', Player.Hits, 'of', Player.HitsMax)

StopScript

StopScript()

Cancels script execution. Any open Script-UI windows are destroyed when the script ends. Returns: true

Example
if Player.IsDead then
    Messages.Error('Player died - stopping.')
    StopScript()
end

Console

Console.clear

Console.clear()

Registered by the assistant, but not documented yet.

Example
Console.clear()

Console.debug

Console.debug(message)

Registered by the assistant, but not documented yet.

ParameterMeaning
message Text to log.
Example
Console.debug('state = idle')

Console.error

Console.error(message)

Registered by the assistant, but not documented yet.

ParameterMeaning
message Text to log.
Example
Console.error('target not found')

Console.info

Console.info(message)

Registered by the assistant, but not documented yet.

ParameterMeaning
message Text to log.
Example
Console.info('found ' .. 3 .. ' corpses')

Console.log

Console.log(message)

Unlike print, Console output goes only to the debug console, not to the in-game message area.

ParameterMeaning
message Text (or number/boolean) to log.
Example
Console.log('loot pass started')

Console.warn

Console.warn(message)

Registered by the assistant, but not documented yet.

ParameterMeaning
message Text to log.
Example
Console.warn('backpack almost full')

Player

Player.Attack

Player.Attack(serial)

The serial must belong to a mobile; item serials are rejected. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the mobile to attack.
Example
local enemy = Mobiles.FindByName('a lich')
if enemy then
    Player.Attack(enemy.Serial)
end

Player.ClearHands

Player.ClearHands(hand)

Accepts 'left', 'right' or 'both'. Items blocked by the pickup filter are not moved. With 'both', a short delay is inserted between the two moves. Returns: true on success, false otherwise.

ParameterMeaning
hand 'left', 'right' or 'both'.
Example
Player.ClearHands('both')
Pause(600)
Spells.Cast('Recall')

Player.ClickObject

Player.ClickObject(serial)

Triggers the object's name/properties display, just like a manual single click. Returns: true on success, false if the serial is invalid.

ParameterMeaning
serial Serial of the object to click.
Example
Player.ClickObject(0x40001234)

Player.DropInBackpack

Player.DropInBackpack()

Works on the item lifted by Player.PickUp (including one still queued for lifting). Returns false if you are not holding an item. Returns: true on success, false otherwise.

Example
Player.PickUp(0x40001234)
Pause(600)
Player.DropInBackpack()

Player.DropInContainer

Player.DropInContainer(containerSerial)

The container may be inside your backpack (searched recursively), on the ground within 2 tiles, or a nearby mobile (its backpack is used, e.g. a pack horse). Returns false if no container is found or nothing is held. Returns: true on success, false otherwise.

ParameterMeaning
containerSerial Serial of the target container or mobile.
Example
Player.PickUp(0x40001234)
Pause(600)
Player.DropInContainer(0x40005678)

Player.DropOnGround

Player.DropOnGround()

Returns: true on success, false if nothing is held.

Example
Player.PickUp(0x40001234)
Pause(600)
Player.DropOnGround()

Player.Equip

Player.Equip(serial)

Returns false if the serial is invalid or the item type is blocked from assistant pickup. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the item to equip.
Example
local sword = Items.FindByType(0x0F5E)
if sword then
    Player.Equip(sword.Serial)
end

Player.PickUp

Player.PickUp(serial[, amount])

Follow up with Player.DropInBackpack, Player.DropInContainer or Player.DropOnGround. Amount defaults to 1. Items blocked by the pickup filter cannot be lifted. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the item to pick up.
amount optional Stack amount to lift (default 1).
Example
local gold = Items.FindByType(0x0EED)
if gold then
    Player.PickUp(gold.Serial, gold.Amount)
    Pause(600)
    Player.DropInBackpack()
end

Player.PopPouch

Player.PopPouch()

Finds a trapped pouch (graphic 0x0E79, hue 0x0025) in your backpack and double-clicks it. Returns false if you are dead or no trapped pouch is found. Returns: true on success, false otherwise.

Example
if Player.IsParalyzed then
    Player.PopPouch()
end

Player.Say

Player.Say(text[, hue[, type[, font]]])

With only the text argument, speaks normally. Optional hue, message type and font can be passed for advanced use. Returns: true on success, false on error.

ParameterMeaning
text The text to say.
hue optional Text color hue.
type optional Numeric message type.
font optional Font index.
Example
Player.Say('bank')

Player.SayAlliance

Player.SayAlliance(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to send.
Example
Player.SayAlliance('Meet at the moongate.')

Player.SayChat

Player.SayChat(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to send.
Example
Player.SayChat('hello')

Player.SayEmote

Player.SayEmote(text)

Returns: true on success, false on error.

ParameterMeaning
text The emote text.
Example
Player.SayEmote('waves')

Player.SayGuild

Player.SayGuild(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to send.
Example
Player.SayGuild('Rare spawn up!')

Player.SayParty

Player.SayParty(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to send.
Example
Player.SayParty('Healing in 3 seconds!')

Player.SayWhisper

Player.SayWhisper(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to whisper.
Example
Player.SayWhisper('psst')

Player.SayYell

Player.SayYell(text)

Returns: true on success, false on error.

ParameterMeaning
text The text to yell.
Example
Player.SayYell('Guards!')

Player.ToggleWarMode

Player.ToggleWarMode()

Returns: true on success, false on error.

Example
Player.ToggleWarMode()

Player.Turn

Player.Turn(direction)

Direction is a name like 'North', 'East', 'Down' etc. The call is rate-limited (about 200 ms mounted, 400 ms on foot) and returns false when called too quickly. If you already face that direction, nothing happens. Returns: true on success, false if rate-limited or the name is invalid.

ParameterMeaning
direction Direction name, e.g. 'North', 'South', 'East', 'West'.
Example
Player.Turn('North')

Player.UseObject

Player.UseObject(serial)

Returns false if the serial does not exist in the game world, or if the item type is blocked by the shard's scripting restrictions. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the object to use (e.g. 0x40001234).
Example
local bandage = Items.FindByType(0x0E21)
if bandage then
    Player.UseObject(bandage.Serial)
end

Player.UseObjectByType

Player.UseObjectByType(graphic)

Searches your hands first, then your own items, then world items within 2 tiles. Returns false if nothing matches or the type is blocked by scripting restrictions. Returns: true if an item was found and used, false otherwise.

ParameterMeaning
graphic Item graphic id (e.g. 0x0E21 for bandages).
Example
-- use a bandage without searching manually
Player.UseObjectByType(0x0E21)

Items

Items.CountType

Items.CountType(graphic[, hue])

Sums stack amounts, so 3 stacks of 100 gold return 300. Searches recursively through bags inside your backpack. Returns: total amount as a number (0 if none).

ParameterMeaning
graphic Item graphic id to count.
hue optional Only count items with this hue.
Example
local bandages = Items.CountType(0x0E21)
if bandages < 10 then
    Messages.Warning('Restock bandages!')
end

Items.CountTypeInContainer

Items.CountTypeInContainer(containerSerial, graphic[, hue])

Returns: total amount as a number (0 if none or container not found).

ParameterMeaning
containerSerial Serial of the container to search.
graphic Item graphic id to count.
hue optional Only count items with this hue.
Example
local ingots = Items.CountTypeInContainer(0x40005678, 0x1BF2)
print('Ingots in chest: ' .. ingots)

Items.FindByFilter

Items.FindByFilter(filter)

The filter is a table; every key is optional and all given conditions must match. Supported keys: graphic (number), graphics (number or list of numbers), hue (number), hues (number or list), rangemin/rangemax (distance in tiles), container (container serial), onground (boolean), corpse (boolean), iscontainer (boolean), movable (boolean), name (substring, case-insensitive), layers (number or list of layer numbers). Returns a Lua array of item tables (empty when nothing matches). Returns: array of item tables (possibly empty).

ParameterMeaning
filter Table of filter conditions (see description).
Example
-- all corpses within 2 tiles
local corpses = Items.FindByFilter({ corpse = true, rangemax = 2 })
for i, corpse in ipairs(corpses) do
    print(i, corpse.Name)
end

Items.FindByLayer

Items.FindByLayer(layer)

Layer is the numeric equipment layer (e.g. 1 = right hand, 2 = left hand, 21 = backpack). Returns nil if the layer is empty. Returns: item table or nil.

ParameterMeaning
layer Numeric equipment layer.
Example
local weapon = Items.FindByLayer(1)
if weapon then
    print('Wielding: ' .. weapon.Name)
end

Items.FindByName

Items.FindByName(name)

Returns: item table or nil.

ParameterMeaning
name Exact item name.
Example
local key = Items.FindByName('a house key')
if key then
    Player.UseObject(key.Serial)
end

Items.FindBySerial

Items.FindBySerial(serial)

Returns an item table (see the Item object reference) or nil if the item does not exist or its type is hidden by the shard's scripting restrictions. Returns: item table or nil.

ParameterMeaning
serial Serial of the item (e.g. 0x40001234).
Example
local item = Items.FindBySerial(0x40001234)
if item then
    print(item.Name, item.Amount)
end

Items.FindByType

Items.FindByType(graphic)

Searches your own items first, then the rest of the world. Returns an item table or nil. Returns: item table or nil.

ParameterMeaning
graphic Item graphic id (e.g. 0x0EED for gold coins).
Example
local bandage = Items.FindByType(0x0E21)
if bandage == nil then
    Messages.Warning('Out of bandages!')
end

Items.FindInContainer

Items.FindInContainer(containerSerial[, graphic[, hue]])

Accepts a container serial or a mobile serial (its backpack is used). Only direct children are returned, not the contents of nested containers. Returns nil if the serial is not a container. Returns: array of item tables, or nil if the container was not found.

ParameterMeaning
containerSerial Serial of the container (or a mobile whose backpack to search).
graphic optional Only return items with this graphic.
hue optional Only return items with this hue.
Example
local pack = Player.Backpack
local regs = Items.FindInContainer(pack.Serial, 0x0F7A)
print('Black pearl stacks: ' .. #regs)

Items.GetContainerItems

Items.GetContainerItems(containerSerial)

Same as Items.FindInContainer without filters: direct children only, mobile serials resolve to the mobile's backpack. Returns nil if the serial is not a container. Returns: array of item tables, or nil.

ParameterMeaning
containerSerial Serial of the container.
Example
local loot = Items.GetContainerItems(corpse.Serial)
for _, item in ipairs(loot) do
    print(item.Name)
end

Mobiles

Mobiles.FindByFilter

Mobiles.FindByFilter(filter)

The filter is a table; every key is optional and all given conditions must match. Supported keys: dead (boolean), female (boolean), human (boolean), poisoned (boolean), paralized (boolean - note the spelling), rangemin/rangemax (distance in tiles), names (list of exact names), hues (list of numbers), bodies (list of body graphic ids), notorieties (list of strings: 'Innocent', 'Ally', 'Gray', 'Criminal', 'Enemy', 'Murderer', 'Invulnerable'), serials (list of serials). Returns a Lua array of mobile tables (empty when nothing matches). Returns: array of mobile tables (possibly empty).

ParameterMeaning
filter Table of filter conditions (see description).
Example
-- hostile reds within 8 tiles
local reds = Mobiles.FindByFilter({ notorieties = { 'Murderer' }, rangemax = 8, dead = false })
for _, m in ipairs(reds) do
    print(m.Name, m.Distance)
end

Mobiles.FindByName

Mobiles.FindByName(name)

Returns: mobile table or nil.

ParameterMeaning
name Exact mobile name, case-insensitive.
Example
local healer = Mobiles.FindByName('a wandering healer')
if healer then
    print('Healer at ' .. healer.X .. ',' .. healer.Y)
end

Mobiles.FindBySerial

Mobiles.FindBySerial(serial)

Returns: mobile table or nil.

ParameterMeaning
serial Serial of the mobile.
Example
local pet = Mobiles.FindBySerial(0x00012345)
if pet then
    print(pet.Name .. ': ' .. pet.Hits .. '/' .. pet.HitsMax)
end

Mobiles.FindByType

Mobiles.FindByType(body)

Returns: mobile table or nil.

ParameterMeaning
body Body graphic id (e.g. 0x00EE for a rat).
Example
local horse = Mobiles.FindByType(0x00C8)
if horse then
    Player.UseObject(horse.Serial)
end

Mobiles.Rename

Mobiles.Rename(serial, name)

Sends a rename request to the server; the server decides whether the mobile can actually be renamed. Returns: true if the request was sent, false otherwise.

ParameterMeaning
serial Serial of the mobile to rename.
name New name (must not be empty).
Example
Mobiles.Rename(0x00012345, 'Lightning')

Gumps

Gumps.Close

Gumps.Close([gumpId])

Returns: true if a gump was closed.

ParameterMeaning
gumpId optional Server gump id, or 0/omitted for any gump.
Example
Gumps.Close()

See also Gumps.CloseGump

Gumps.CloseGump

Gumps.CloseGump([gumpId])

With no argument (or 0), closes the first open server gump found. Returns false if no matching gump is open. Returns: true if a gump was closed.

ParameterMeaning
gumpId optional Server gump id, or 0/omitted for any gump.
Example
Gumps.CloseGump(0x1F2E4C1D)

Gumps.GetGump

Gumps.GetGump([gumpId])

Returns a gump table with Serial, X, Y, Width, Height and Texts (a 1-indexed array of the gump's text lines) — see the Gump object reference. With no argument (or 0), the first open server gump is used. Returns nil if no matching gump is open. Returns: gump table or nil.

ParameterMeaning
gumpId optional Server gump id, or 0/omitted for any gump.
Example
local gump = Gumps.GetGump()
if gump then
    for i, text in ipairs(gump.Texts) do
        print(i, text)
    end
end

Gumps.HasGump

Gumps.HasGump([gumpId])

With a gump id, checks for that specific gump. With no argument (or 0), returns true if any server gump is open. Returns: true if a matching gump is open.

ParameterMeaning
gumpId optional Server gump id, or 0/omitted for any gump.
Example
if Gumps.HasGump(0x1F2E4C1D) then
    Gumps.Reply(0x1F2E4C1D, 1)
end

Gumps.IsActive

Gumps.IsActive([gumpId])

Returns: true if a matching gump is open.

ParameterMeaning
gumpId optional Server gump id, or 0/omitted for any gump.
Example
if Gumps.IsActive() then print('a gump is open') end

See also Gumps.HasGump

Gumps.PressButton

Gumps.PressButton(gumpId, buttonId)

Returns: true if the button press was queued, false otherwise.

ParameterMeaning
gumpId Server gump id.
buttonId Id of the button to press.
Example
Gumps.PressButton(0x554B87F3, 1)

See also Gumps.Reply

Gumps.Reply

Gumps.Reply(gumpId, buttonId)

Returns false with a warning if the gump is not open. Returns: true if the button press was queued, false otherwise.

ParameterMeaning
gumpId Server gump id.
buttonId Id of the button to press.
Example
Gumps.Reply(0x554B87F3, 1)

Gumps.Send

Gumps.Send(gumpId, buttonId[, switches, textEntries])

Currently only the button press is applied; the switches and textEntries tables are accepted but not yet forwarded to the gump. For plain button presses, prefer Gumps.Reply. Returns: true if the response was queued, false otherwise.

ParameterMeaning
gumpId Server gump id.
buttonId Id of the button to press.
switches optional Table of switch ids (not yet applied).
textEntries optional Table of text entries (not yet applied).
Example
Gumps.Send(0x554B87F3, 1)

Gumps.WaitForGump

Gumps.WaitForGump(gumpId, timeoutMs)

Polls roughly every 100 ms. Pass 0 as gumpId to wait for any server gump. Returns: true if the gump appeared, false on timeout.

ParameterMeaning
gumpId Server gump id to wait for (0 = any).
timeoutMs Maximum time to wait, in milliseconds.
Example
Player.UseObject(runebook.Serial)
if Gumps.WaitForGump(0x554B87F3, 3000) then
    Gumps.Reply(0x554B87F3, 5)
end

Targeting

Targeting.CancelTarget

Targeting.CancelTarget()

Returns: true on success.

Example
if Targeting.IsTargeting() then
    Targeting.CancelTarget()
end

Targeting.GetLastTarget

Targeting.GetLastTarget()

Returns a table with at least Serial; if the last target is a mobile in view, X, Y, Z and Name are included too. Returns nil if no last target is set. Returns: table { Serial [, X, Y, Z, Name] } or nil.

Example
local last = Targeting.GetLastTarget()
if last then
    print('Last target serial: ' .. string.format('0x%08X', last.Serial))
end

Targeting.GetNewTarget

Targeting.GetNewTarget([timeoutMs])

Opens a client-side pick cursor so the user can select an item or mobile. Returns the picked serial as a number, or nil on timeout. Default timeout is 10000 ms. The picked serial also becomes the last target. Returns: picked serial (number) or nil.

ParameterMeaning
timeoutMs optional Maximum time to wait (default 10000).
Example
Messages.Info('Select your loot container...')
local serial = Targeting.GetNewTarget(15000)
if serial then
    Config.Save('MyLooter', { container = serial })
end

Targeting.IsTargeting

Targeting.IsTargeting()

Returns: true if a target cursor is up.

Example
if Targeting.IsTargeting() then
    Targeting.Last()
end

Targeting.Last

Targeting.Last()

If the last target is a mobile or item, it is targeted by serial. Static and land tiles (e.g. a tree you chopped or a mining spot) are replayed from the last target packet - click the tile once by hand, then repeat it from the script. Returns: true on success, false if no last target is available.

Example
Player.UseObjectByType(0x0F43) -- axe
if Targeting.WaitForTarget(3000) then
    Targeting.Last() -- chop the same tree again
end

Targeting.Self

Targeting.Self()

Answers the active target cursor with your own character. Returns: true on success.

Example
Spells.Cast('Cure')
if Targeting.WaitForTarget(3000) then
    Targeting.Self()
end

Targeting.SetLast

Targeting.SetLast(serial)

Returns: true on success.

ParameterMeaning
serial Serial to remember as last target.
Example
Targeting.SetLast(enemy.Serial)

Targeting.TargetSerial

Targeting.TargetSerial(serial)

Answers an active target cursor with the given mobile or item. Returns false if the entity is not in the game world. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the mobile or item to target.
Example
Spells.Cast('Lightning')
if Targeting.WaitForTarget(3000) then
    Targeting.TargetSerial(enemy.Serial)
end

Targeting.WaitForTarget

Targeting.WaitForTarget(timeoutMs)

Polls roughly every 50 ms until the server asks for a target or the timeout expires. Typical pattern: cast a spell, wait for the cursor, then target something. Returns: true when a target cursor is active, false on timeout.

ParameterMeaning
timeoutMs Maximum time to wait, in milliseconds.
Example
Spells.Cast('Greater Heal')
if Targeting.WaitForTarget(3000) then
    Targeting.Self()
end

Spells

Spells.Cast

Spells.Cast(nameOrId)

Names are normalized, so 'Greater Heal', 'greater-heal' and 'GreaterHeal' all work. A numeric spell id is accepted too. Returns false with a warning for unknown spell names. Returns: true if the cast was started, false otherwise.

ParameterMeaning
nameOrId Spell name (e.g. 'Greater Heal') or numeric spell id.
Example
Spells.Cast('Greater Heal')
if Targeting.WaitForTarget(3000) then
    Targeting.Self()
end

Spells.CastById

Spells.CastById(spellId)

Returns: true if the cast was started, false on error.

ParameterMeaning
spellId Numeric spell id (e.g. 29 for Greater Heal).
Example
Spells.CastById(29)

Skills

Skills.GetAll

Skills.GetAll()

The result is keyed by skill name; each entry is a table with Name, Index, Value, Base, Cap and Lock ('Up'/'Down'/'Locked'). Returns: table of skill tables keyed by skill name.

Example
local all = Skills.GetAll()
for name, s in pairs(all) do
    if s.Base >= s.Cap and s.Cap > 0 then
        print(name .. ' is capped')
    end
end

Skills.GetBase

Skills.GetBase(skillName)

Returns: base value as a number (0 if unknown).

ParameterMeaning
skillName Name of the skill.
Example
print('Base Magery: ' .. Skills.GetBase('Magery'))

Skills.GetCap

Skills.GetCap(skillName)

Returns: skill cap as a number (0 if unknown).

ParameterMeaning
skillName Name of the skill.
Example
if Skills.GetBase('Mining') >= Skills.GetCap('Mining') then
    Messages.Info('Mining is capped.')
end

Skills.GetLock

Skills.GetLock(skillName)

Returns: 'Up', 'Down' or 'Locked' (nil if the skill is unknown).

ParameterMeaning
skillName Name of the skill.
Example
print(Skills.GetLock('Magery'))

Skills.GetValue

Skills.GetValue(skillName)

Returns: skill value as a number (0 if the skill is unknown).

ParameterMeaning
skillName Name of the skill.
Example
if Skills.GetValue('Magery') >= 62.5 then
    Spells.Cast('Greater Heal')
end

Skills.SetLock

Skills.SetLock(skillName, lockState)

lockState is a string: 'up' (skill can raise), 'down' (skill lowers), or 'locked' (also accepts 'lock'). Case-insensitive; unrecognized values fall back to locked. Returns: true on success, false if the skill is unknown.

ParameterMeaning
skillName Name of the skill.
lockState 'up', 'down' or 'locked'.
Example
Skills.SetLock('Wrestling', 'locked')
Skills.SetLock('Magery', 'up')

Skills.Use

Skills.Use(skillName)

The name is matched case-insensitively against the skill list (e.g. 'Hiding', 'Meditation'). Returns false if the skill is unknown. Returns: true on success, false otherwise.

ParameterMeaning
skillName Name of the skill to use.
Example
Skills.Use('Hiding')
Pause(10000)

Journal

Journal.Clear

Journal.Clear()

Entries received before this call are ignored by Journal.Contains, ContainsFrom and GetAll. The clear is shared across all scripting engines. Returns: true.

Example
Journal.Clear()
Player.UseObject(forge.Serial)
if Journal.WaitForText('You fail', 5000) then
    print('failed')
end

Journal.Contains

Journal.Contains(text)

Case-insensitive substring search over all entries received since the script started (or since the last Journal.Clear). Returns: true if found.

ParameterMeaning
text Text to search for.
Example
if Journal.Contains('You have been poisoned') then
    Spells.Cast('Cure')
end

Journal.ContainsFrom

Journal.ContainsFrom(text, source)

Like Journal.Contains, but the entry's speaker name must also match (case-insensitive, exact name). Returns: true if found.

ParameterMeaning
text Text to search for.
source Name of the speaker (e.g. an NPC name).
Example
if Journal.ContainsFrom('I will train you', 'Gareth') then
    Player.Say('train magery')
end

Journal.GetAll

Journal.GetAll()

Entries are in chronological order; each is a table with Text, Name, Hue and Time ('HH:mm:ss'). Returns: array of entry tables.

Example
for _, entry in ipairs(Journal.GetAll()) do
    Console.log(entry.Text)
end

Journal.GetLast

Journal.GetLast([count])

Returns up to count entries, newest first (default 1). Each entry is a table with Text, Name (speaker), Hue and Time ('HH:mm:ss'). Note: GetLast ignores the Journal.Clear filter. Returns: array of entry tables, newest first.

ParameterMeaning
count optional How many entries to return (default 1).
Example
local last = Journal.GetLast(5)
for i, entry in ipairs(last) do
    print(entry.Time, entry.Name, entry.Text)
end

Journal.WaitForText

Journal.WaitForText(text, timeoutMs)

Only entries received after this call is made are considered; older entries never match. Polls roughly every 100 ms. Case-insensitive substring search. Returns: true if the text appeared, false on timeout.

ParameterMeaning
text Text to wait for.
timeoutMs Maximum time to wait, in milliseconds.
Example
Skills.Use('Tracking')
if Journal.WaitForText('You see no evidence', 4000) then
    Messages.Info('Nothing nearby.')
end

Messages

Messages.Error

Messages.Error(text)

Returns: true on success.

ParameterMeaning
text Text to show.
Example
Messages.Error('Runebook not found - stopping.')

Messages.Info

Messages.Info(text)

Returns: true on success.

ParameterMeaning
text Text to show.
Example
Messages.Info('Script started.')

Messages.Overhead

Messages.Overhead(text[, hue])

Returns: true on success.

ParameterMeaning
text Text to show.
hue optional Text color hue (default 946).
Example
Messages.Overhead('Healing!', 68)

Messages.OverheadMobile

Messages.OverheadMobile(serial, text[, hue])

Returns false if the mobile is not in view. Returns: true on success, false otherwise.

ParameterMeaning
serial Serial of the mobile.
text Text to show.
hue optional Text color hue (default 946).
Example
Messages.OverheadMobile(pet.Serial, 'Low HP!', 33)

Messages.Print

Messages.Print(text[, hue])

Returns: true on success.

ParameterMeaning
text Text to show.
hue optional Text color hue (default 946).
Example
Messages.Print('Loot pass done.', 68)

Messages.Warning

Messages.Warning(text)

Returns: true on success.

ParameterMeaning
text Text to show.
Example
Messages.Warning('Low on reagents!')

Config

Config.Delete

Config.Delete(name)

Returns: true if a file was deleted, false otherwise.

ParameterMeaning
name Config name.
Example
Config.Delete('MyLooter')

Config.Exists

Config.Exists(name)

Returns: true if the config file exists.

ParameterMeaning
name Config name.
Example
if not Config.Exists('MyLooter') then
    Messages.Info('First run - using defaults.')
end

Config.Load

Config.Load(name)

Returns the saved table, or nil if the config does not exist. JSON objects and arrays become tables, numbers become Lua numbers. Returns: table or nil.

ParameterMeaning
name Config name used with Config.Save.
Example
local cfg = Config.Load('MyLooter')
if cfg == nil then
    cfg = { enabled = true }
end

Config.Save

Config.Save(name, table)

Supports strings, numbers, booleans, nested tables and arrays. Files are stored as .json in the Config subfolder of the Lua scripts folder (Data/LuaScripts/Config/) and can be edited by hand. The name must be a plain file name without paths. Returns: true on success, false otherwise.

ParameterMeaning
name Config name, e.g. 'MyLooter'.
table Table of settings to save.
Example
Config.Save('MyLooter', {
    container = 0x40001234,
    enabled = true,
    graphics = { 0x0EED, 0x0F7A }
})

Script UI

UI.DestroyAll

UI.DestroyAll()

Returns: true.

Example
UI.DestroyAll()

UI.Pump

UI.Pump()

Usually not needed: Pause() pumps automatically and win:Run() pumps in a loop. Use UI.Pump() only in custom loops that never call Pause. Returns: true.

Example
while myWindowOpen do
    UI.Pump()
    Pause(50)
end

UI.Window

UI.Window(title[, x, y[, width, height]])

Also accepts a table form: UI.Window{ title = 'Helper', x = 100, y = 100, width = 250, height = 300 }. Elements stack vertically with auto-layout (use win:Row() for a horizontal group). Callbacks and bindings are pumped automatically during Pause(); win:Run() is the convenience loop that waits until the window is closed. All windows are destroyed when the script ends. Returns: window table, or nil on error.

ParameterMeaning
title Window title (or an options table, see description).
x optional Screen X position.
y optional Screen Y position.
width optional Window width.
height optional Window height.
Example
local win = UI.Window('Helper')
win:Label(function() return 'HP: ' .. Player.Hits end)
local status = win:Label('Ready')
win:Button('Heal', function()
    status:SetText('Casting...')
    Spells.Cast('Greater Heal')
end)
local auto = win:Checkbox('Auto-heal', false)
win:Run()  -- pumps callbacks until the window is closed