Your first script#
RynthLua runs Lua scripts inside the game, in the same shape as UtilityBelt's scripting. Here is a small one from start to finish.
Make a folder called
HelloinC:\Games\RynthSuite\RynthLua\Scripts\and put a file calledindex.luain it:-- Hello: my first script print("Hello, " .. game.Character.Name .. "!") game.RegisterCommand("/hello", function(args) print("You typed /hello " .. args) end) game.Character.OnVitalChanged.Add(function(e) if e.TypeName == "Health" and e.Value < game.Character.MaxHealth * 0.3 then print("Health is low: " .. e.Value) end end)Open the Lua window (RynthCore bar Lua) and press Run beside Hello, or type
/lua start Hello.The script's console in the Lua window shows its
printlines. Type/hello thereto try the command.Stop it with Stop, or
/lua stop Hello. A script that has nothing left to do (no handlers, commands or threads) ends by itself.
Scripts never freeze the game: each one gets a slice of every game tick, and sleep and await pause only that script.
Where scripts live#
Everything lives under C:\Games\RynthSuite\RynthLua\:
| Path | What |
|---|---|
Scripts\<Name>\index.lua | A folder script. Other .lua files in the folder load with require("file") (dots are subfolders: require("lib.util") is lib\util.lua); never outside the folder. |
Scripts\<Name>\script.json | Optional manifest of a folder script. |
Scripts\<Name>.lua | A single-file script (v1 scripts, the panel editor's scripts). Can only require built-in modules. A folder script wins over a file of the same name. |
Data\<Name>\ | The script's data folder: storage.json, characters\<server>_<character>.json (the storage module), and whatever it writes with filesystem. |
settings.json | RynthLua's own settings: which scripts autostart. |
editor.lua | The panel editor's unsaved text. |
hud_visibility.json | Which script windows the player left open or closed, per character (see "Script windows"). |
resume.json | Written when RynthLua shuts down: the scripts to start again after a hot reload (below). Read and deleted when RynthLua loads. |
script.json(every field optional):{ "name", "description", "version", "author", "autostart": "none" | "global" | "character" }. The description shows in the panel (name, version and author aren't used yet). The script's name is always its folder name.autostartis only a default: it is applied once per script (the first login that sees it), after that the player's choice in the panel or/lua autostartrules. Missing means "none".- Autostart runs at login: "global" scripts start on every character (and keep running across logouts), "character" scripts on that character only (kept per "server|character").
- On first run, when
Scripts\doesn't exist yet, RynthLua copies the scripts from RynthAi's oldC:\Games\RynthSuite\RynthAi\LuaScripts\, or, if there were none, writes three single-file starters: "Example - Hello", "Example - Wisp Essence", "Example - Tells". - Several scripts run at once, each in its own Lua state (
ScriptContext+LuaScriptHost). One script per name; starting a running script restarts it./lua execcode runs as a script calledexec, the panel editor's as the name it was given (defaulteditor). - A script keeps running while it has something to do: a live thread (the main chunk, a
spawn, a handler that is sleeping or awaiting), an event handler (v1onor v2.Add/.Once/.Until), a registered chat command, or a globalOnBotTick. When none is left it ends ("finished"). - Stopping a script drops everything it registered: event handlers, commands, its queued and running actions (they finish as Cancelled), and flushes its storage.
- At logout every script stops, including ones started by hand, except the "global" autostart ones.
- After a hot reload (the engine's, or RynthLua's own), the scripts come back at the next login event, which the engine sends by itself when you are in the world: autostart ones as usual, and the ones started by hand from a file too. On shutdown RynthLua writes
resume.jsonwith the running file scripts that have no autostart, with the process id and the time. On load it keeps that list only when the file comes from the same client process and is under 60 s old, so a new client never restarts them. They start after autostart (a script already running isn't started twice), each on its own, and only if the login comes within 2 minutes of the reload. The editor's and/lua execscripts aren't resumed. The log says[RynthLua] resuming N script(s) after a reload, thenResumed <name>.orResume <name>: <why not>for each. - The CPU budget: 4 ms per game tick across all scripts; a thread is forced to pause every 5000 Lua instructions and resumed while the tick's budget lasts. Scripts, and threads within a script, are resumed round-robin, so one busy script can't starve the others.
- Each script has a console (the Lua panel, last 400 lines).
printwrites there, errors too (with the line number); an error ends that thread only, not the script.
API reference#
Types in this section: id is a number, obj a WorldObject or an id, [x] optional.
Globals#
| Global | What |
|---|---|
game | The v2 root (below). |
sleep(ms), wait(ms) | Park this thread for ms. |
await(action) | Park until the action has finished; returns it. Errors when given something that isn't a table. |
waitfor(cond [, timeoutMs]) | Check cond() every 100 ms; true when it held, false on timeout. |
spawn(fn, ...) | Run fn(...) as a new thread of this script. |
stop() | Stop this script. |
clock() | Milliseconds since Windows started (the clock StartedAt/FinishedAt use). |
print(...) | To this script's console. |
require(name) | A built-in module or a file in the script's folder; cached per script. |
ObjectClass, ObjectType, SkillId, AttributeId, VitalId, CombatMode, IntId, Int64Id, FloatId, StringId, BoolId, DataId, InstanceId, EquipMask, ChatType / ChatMessageType, ChatChannel, ClientState, DistanceType, AddRemoveEventType, SkillTrainingType, MaterialType, ... | Enum tables with UtilityBelt's names and numbers (see enums for the full list). |
ActionError | Every UtilityBelt ActionError name, ActionError.TooBusy == "TooBusy". |
ActionType | UB's action priorities: Immediate 2147483647, Wield 20000, RestoreHealth 19000, RestoreStamina 18000, RestoreMana 17000, LoginLogoff 16000, Vendor 15500, Trade 15000, Combat 14000, CastSpell 13000, Navigation 12000, Fellow 11000, Allegiance 10000, Inventory 9000, Misc 8000. |
ActionOptions | UB's options type: ActionOptions.new() (or ActionOptions()) returns an options table to fill in (Name, Priority, SkipChecks, MaxRetryCount, TimeoutMilliseconds). A plain table works just as well. |
| v1 | chat, command, expr, meta, getvar, setvar, me, RynthAi, Settings, on, off, OnBotTick (see "v1 API"). |
Lua's own libraries: MoonSharp's soft sandbox (string, table, math, bit32, coroutine, metatables, pcall/error, os.time/os.date/os.clock/os.difftime). No io, no os.execute, no debug. The global json is the same module require("json") returns.
Lists. Every list the API returns (GetAll, wo.Items, game.Character.Inventory, KnownSpellsIds, ...) is a 1-based Lua table: #list, list[i] and ipairs(list) work, and so does iterating it directly, for wo in list do ... end, the way a CLR list is iterated in UtilityBelt's Lua. Calling a list returns it (so the older call forms such as wo:Items() still work); game.Character.Inventory(filter) and its two siblings filter.
Events#
An event is an object with four functions (UB's names, also in lower case):
evt.Add(fn)/evt.add(fn): callfn(e)every time.evt.Once(fn)/evt.once(fn): the next time only.evt.Until(fn)/evt.until(fn): every time untilfnreturns true (events that were already on their way when it did are skipped).evt.Remove(fn)/evt.remove(fn): remove a handler added with any of the three.
Handlers get one table argument with named fields (a plain table: a handler may write to it, e.g. e.Eat = true). Each call runs as its own coroutine (so it may sleep/await); calls start in the order their events happened; errors print to the console and don't remove the handler.
| Event | Args |
|---|---|
game.OnTick (also game.World.OnTick) | {}, every plugin tick. A loop with sleep is usually better. |
game.OnStateChanged | { NewState } ("CharacterSelect", "InGame", "LoggingOut"; compare with ClientState.In_Game etc.) |
game.OnScriptEnd | {}; this script is being stopped by /lua stop, the panel, a restart or logout. The handler gets about 5 ms. |
game.World.OnObjectCreated | { ObjectId, Object } |
game.World.OnObjectReleased | { ObjectId } (the object is gone) |
game.World.OnChatText | { Message, Type, SenderName, SenderId, Room, Eat } (UB's ChatEventArgs): every chat window line; Type a ChatMessageType number; SenderName/SenderId "" / 0 unless the line is "X says, ..." / "X tells you, ..."; Room a ChatChannel number for "[General] ..." lines, else 0; Eat false (see below) |
game.World.OnTell | the same args: incoming tells only (ChatMessageType.Tell); Message is the text inside the quotes; SenderId 0 when the line had no name link |
game.World.OnLocalMessage | the same args: "X says, ..." lines (ChatMessageType.Speech); Message inside the quotes |
game.World.OnChannelMessage | the same args: "[Room] X says, ..." lines of a chat room (Allegiance, General, Trade, LFG, Roleplay, Olthoi, Society, Celestial Hand, Eldrytch Web, Radiant Blood); Room says which |
game.World.OnFellowMessage | the same args: "[Fellowship] X says, ..." lines |
game.World.OnEmote | the same args: ChatMessageType.Emote lines; Message is the whole line, no sender |
game.World.OnChatInput | { Text, Eat }: a line you typed, on the next tick. Setting e.Eat = true for a line that starts with "/word" can't stop that line any more (AC already took it), but from then on RynthLua eats every line starting with that word as it is typed, until the script stops, and handlers get those lines with Eat already true. game.RegisterCommand eats from the first line. |
game.World.OnSelected (also OnObjectSelected) | { ObjectId, PreviousId, Object }; ObjectId 0 and no Object when the selection was cleared |
game.World.OnContainerOpened / OnContainerClosed | { Container }: a container on the ground (chest, corpse) was opened / closed |
game.World.Vendor.OnOpened / OnClosed | {} |
wo.OnPositionChanged | { Weenie, Position } for that object (Position as ServerPosition); checked every tick while a script listens |
wo.OnDestroyed | { ObjectId } when that object is released |
game.Character.OnVitalChanged | { Type, TypeName, Value, OldValue }: Type a VitalId (Health 1, Stamina 3, Mana 5), TypeName "Health"/"Stamina"/"Mana"; current values |
game.Character.OnPortalSpaceEntered | {} |
game.Character.OnPortalSpaceExited | {} |
game.Character.OnDeath | { Text, KillerId }: the death line from chat, or ""; KillerId is always 0 (not known) |
game.Character.OnCombatModeChanged | { NewMode, OldMode, NewModeName, OldModeName } |
game.Character.OnEnchantmentsChanged | { Type, TypeName, SpellId, LayeredSpellId, Name, Refreshed, Enchantment }: one event per enchantment; Type 0 = Added, 1 = Removed (AddRemoveEventType.Added/.Removed); LayeredSpellId is { Id }; Refreshed true when a running one was cast again; Name needs RynthAi; Enchantment as in Enchantments(). On engine API v70+ it follows the server's enchantment messages (the next tick after the change); older engines poll every 500 ms |
game.Character.OnLevelChanged | { Level, OldLevel } |
game.Character.OnVitaeChanged | { Vitae, OldVitae } (1.0 = no penalty) |
game.Character.OnTotalExperienceChanged | { TotalExperience, OldTotalExperience } |
game.Character.OnAvailableLuminanceChanged | { AvailableLuminance, OldAvailableLuminance } |
game.Character.Trade.OnStarted | { InitiatorId, PartnerId } |
game.Character.Trade.OnObjectAdded | { ObjectId, Side } (TradeSide.Self 1, TradeSide.Partner 2) |
game.Character.Trade.OnAccepted / OnDeclined / OnReset | { AcceptorId } / { DeclinerId } / { ResetterObjectId } |
game.Character.Trade.OnFailedToAddObject | { ObjectId, Reason } (a WeenieError number) |
game.Character.Trade.OnCompleted | { PartnerId, YourItemIds, PartnerItemIds } |
game.Character.Trade.OnEnded | { Reason } (1 normal, 2 entered combat, 0x51 cancelled) |
game#
| Member | What |
|---|---|
ServerName, AccountName | Text ("" when unknown). |
CharacterId | Your id, 0 before login. |
State | "CharacterSelect", "InGame" or "LoggingOut"; game.State == ClientState.In_Game works (the ClientState values are these texts). |
LastTick | clock() at the start of the current tick. |
ScriptName | This script's name. |
Capabilities | UB's Capabilities.Has(ClientCapability.ImGui) / Get(): ImGui (1) when the engine can show script windows. |
Character, World, Actions, ActionQueue | Below. |
OnTick, OnStateChanged, OnScriptEnd | Events (above). |
RegisterCommand("/name", fn) | A chat command owned by this script. A typed line whose first word is the command (any case) is eaten, and fn(args) runs next tick with the rest of the line. The slash is added when missing. Another script's command is an error. Commands keep the script running. |
UnregisterCommand("/name") | Drop one of this script's commands. |
game.World#
The objects the client knows: everything created since RynthLua loaded, your inventory, and (engine API v69 and later) the engine's whole object table, refreshed every second.
| Member | What |
|---|---|
Get(id) | The WorldObject, or nil when the client doesn't know it. Also takes "12345" or "0x80001234". |
TryGet(id) | UB's form: local ok, wo = game.World.TryGet(id) (false, nil when unknown). |
game.World[id] | The same as Get(id). |
Exists(id) | True when the client knows it. |
GetAll([filter]) | Every known object that matches. |
GetLandscape([filter]) | Objects lying in the world: not you, not in a container, not wielded. |
GetInventory([filter]) | Everything you carry: main-pack items, side packs and their contents, and what you wear and wield. |
GetNearest(filter [, distanceType]) | The nearest landscape object that matches, or nil. A function filter is tried nearest first. DistanceType.T3D (the default) measures in 3D, DistanceType.T2D on the ground plane. |
Selected | The selected object, or nil. |
OpenContainer | The container on the ground you have open (chest, corpse), or nil. |
Vendor | The open vendor: IsOpen, VendorId, Name, MinBuyValue, MaxBuyValue, Magic (1 when it deals in magic items), BuyPriceModifier, SellPriceModifier, CurrencyType (0 = pyreals, else the currency's WCID), CurrencyName, PlayerCurrencyAmount, Category (an ObjectType value: what it buys), Items (a list of { ObjectId, Name, Amount, UnitPrice, StackSize, MaxStackSize, ObjectType }, Amount -1 for unlimited), OnOpened, OnClosed. Engine API v67+. |
| events | OnObjectCreated, OnObjectReleased, OnChatText, OnTell, OnLocalMessage, OnChannelMessage, OnFellowMessage, OnEmote, OnChatInput, OnSelected / OnObjectSelected, OnContainerOpened, OnContainerClosed, OnTick. |
A filter is a name substring (any case), an ObjectClass number (ObjectClass.Monster), the exact ObjectClass name as text ("Monster", "Portal", case matters), an ObjectType value (ObjectType.Creature; every flag in it must be set), or function(wo) return true/false end. World filter functions can't sleep/await.
WorldObject#
A table with the raw field Id; every other property is read live when indexed. tostring(wo) is "Name [0x80001234]"; a == b compares ids.
| Property | What |
|---|---|
Id, Name, WeenieClassId | |
ObjectClass | Number (compare with ObjectClass.X); the name is ObjectClassName. Classified from the object's description flags and item type, like Decal/UB. |
ObjectType | AC ItemType flags as an ObjectType value: wo.ObjectType == ObjectType.Creature, wo.ObjectType:HasFlags(ObjectType.Creature), :ToNumber(). |
ContainerId, WielderId | 0 when none. |
Container, Wielder | WorldObjects, or nil. |
CurrentWieldedLocation | EquipMask number, 0 when not wielded. |
ValidWieldedLocations, ClothingPriority, Material, AmmoType, TargetType, CombatUse, RadarColor, RadarBehavior, IconEffects, CombatMode | Numbers (IntId 9, 4, 131, 50, 94, 51, 95, 133, 18, 40); compare with EquipMask, CoverageMask, MaterialType, ... CombatMode is live for you. |
ObjectDescriptionFlag, PhysicsState | The description bitfield (compare with ObjectDescriptionFlag.X) and the last physics state the server sent (PhysicsState.X; 0 when none was seen). |
Burden, StackSize | Numbers (StackSize is 1 for things that don't stack). Items the client hasn't got full data for can read 0. |
HasAppraisalData | True once the object was appraised (or its data came with it). |
ItemIds, Items | What a container holds directly, not its side packs (ids / WorldObjects). |
ContainerIds, Containers | The side packs it holds. |
AllItemIds, AllItems | Every item it holds, side packs' contents included (not the packs). |
EquipmentIds, Equipment | What it wields and wears. |
SpellIds, SpellId, EnchantmentIds | The spells on an item (a list of { Id }), its casting spell id (DataId.Spell, else its first spell), the enchantments on it ({ Id }). |
ServerPosition | { Landcell, Frame = { Origin = { X, Y, Z }, Orientation = { W, X, Y, Z } } } with pos:DistanceTo2D(other) / pos:DistanceTo3D(other); nil when it has no position (in a pack, wielded, out of view). |
Position | { Landcell, X, Y, Z, NS, EW } or nil (things in packs have none). NS/EW are map coordinates, north and east positive. |
Vitals, Skills, Attributes | On your own weenie (game.Character.Weenie): the same stat objects as game.Character.Vitals etc., the UB way (Weenie.Vitals[VitalId.Health].Current). Empty on other objects. |
OnPositionChanged, OnDestroyed | Events for this object (see Events). |
| Method | What |
|---|---|
Value(key [, default]) | UB's property read: the key's enum picks the kind: wo:Value(IntId.Value) (a plain number is an IntId), wo:Value(StringId.Name), FloatId, BoolId, DataId, Int64Id, InstanceId (Container and Wielder only). default when the object doesn't have it (UB's: 0, "" or false). wo:Value() with no key is the pyreal value. |
HasValue(key) | Whether the object has that property. |
IntValue(id [, default]) | An int property (IntId.X); default (0) when it has none. |
Int64Value, FloatValue, StringValue, BoolValue, DataValue | The same for int64, float, string (""), bool (false) and data-id properties. |
DistanceTo(obj), DistanceTo3D(obj) | Metres; math.huge when a position is unknown. |
DistanceTo2D(obj), DistanceTo2d(id) | Metres on the ground plane. |
GetTopmostParent() | The outermost container or wielder holding it (itself when nothing does). |
Use([options] [, callback]) | Queues ObjectUse(wo). |
UseOn(target, ...) | ObjectUseOn(wo, target) |
Give(target, ...) | ObjectGive(wo, target) |
Move(container [, slot [, stack]], ...) | ObjectMove(wo, container, slot, stack) |
Split(amount [, container [, slot]], ...) | ObjectSplit(wo, container, amount, slot) |
Drop(...), Select(...), Appraise(...), Wield([slot], ...) | The matching action. |
AddToSalvage(...), AddToTrade(...), Inscribe(text, ...) | SalvageAdd(wo), TradeAdd(wo), Inscribe(wo, text) (the last fails: needs engine support). |
Salvage(...) | RunAllOrdered({ SalvageAdd(wo), Salvage() }), as in UB. |
The action methods take the same trailing options table and callback as game.Actions and return the action.
game.Character#
Read live on every access. Before login numbers read 0 (Vitae 1) and text "".
| Member | What |
|---|---|
Id, Name, Level | |
Weenie | You, as a WorldObject. |
CombatMode, CombatModeName | Number (CombatMode.NonCombat 1, Melee 2, Missile 4, Magic 8) and "NonCombat"/"Melee"/"Missile"/"Magic". |
InPortalSpace | |
Vitae | 1.0 = no penalty, 0.9 = 10% vitae. |
Busy, IsBusy() | Busy with a use or a cast. |
AnswerNextPrompt([type [, timeoutMs [, minPercent]]]) | The server's next yes/no prompt of type (a ClientConfirmationType, default YESNO) that comes within timeoutMs (default 5000, at most 30000; 0 disarms) is answered for the script, without the client showing its dialog: Yes when the server's "N percent chance" is at least minPercent (default 0: always), else No. One-shot, one slot per client (RynthAi's tinkering uses it too). Arm it just before the action that brings the prompt, for as short as you can: whatever prompt of that type comes next gets the answer. True when armed; false on an engine before API v85 or an unknown type. |
LastPrompt | The last server prompt this session, or nil: { Seq, Type, ContextId, Percent, Outcome, AgeMs }. Percent is -1 when its text has none; Outcome is "Shown" (nothing armed: the client showed its dialog), "Accepted", "Declined", "SendFailed" or "AcceptedSticky". |
Health, Stamina, Mana, MaxHealth, MaxStamina, MaxMana | Current and buffed maximum. |
BurdenUnits, MaxBurdenUnits, Burden | Carried, capacity (Strength x 150, +30 per point per carrying-capacity augmentation), and percent of capacity. |
TotalExperience, UnassignedExperience, AvailableLuminance, MaximumLuminance | |
Vitals | Vitals.Health, .Stamina, .Mana (also Vitals[VitalId.Health]): { Id, Type, Name, Current, Max, Base } (Max buffed, Base unbuffed; Type is UB's name for the id). VitalId is UB's: Health 1, Stamina 3, Mana 5. |
Vital(v) | The same object, by VitalId or name. |
Skills | Every skill keyed by SkillId (pairs lists them; Skills.WarMagic works too): { Id, Type, Name, Current, Base, Training, TrainingName, IsTrained }. Training is a SkillTrainingType number: 0 Unusable, 1 Untrained, 2 Trained, 3 Specialized. |
Skill(s) | One skill, by SkillId or name ("WarMagic", "war magic"); an unknown one is an error. |
Attributes, Attribute(a) | The same for attributes: { Id, Type, Name, Current, Base }; Attributes.Strength ... Attributes.Self. |
Enchantments() (also UB's ActiveEnchantments(), AllEnchantments()) | A list of { SpellId, Name, Permanent, Remaining, ExpiresAt, Duration }: Remaining seconds left, ExpiresAt Unix time in seconds (both math.huge when permanent, nil when the server time isn't known), Duration in seconds when known (-1 when permanent), Name with RynthAi. |
HasEnchantment(spell) | By spell id, or by name (names need RynthAi). |
KnowsSpell(id) | In your spellbook. |
SpellBook | SpellBook.Count, SpellBook.IsKnown(id), SpellBook.KnownSpellsIds (UB's list property, sorted), SpellBook.KnownSpellIds() (the same, as a call), SpellBook.Name(id) (needs RynthAi; nil when unknown). |
Inventory | Everything you have (a list): packs, their contents, and what you wear and wield. Inventory(filter) filters. |
Equipment | What you wear and wield; Equipment(filter). |
Containers | Your side packs; Containers(filter). |
GetInventory(filter) | UB's: the matching items (a list). |
GetFirstInventory(filter) | UB's: the first matching item, or nil. |
GetInventoryCount(filter), InventoryCount(filter) | How many, counting stack sizes: GetInventoryCount("Pyreal"). |
Trade | The trade window (engine API v72+): IsOpen, PartnerId, YourItemIds, PartnerItemIds, YouAccepted, PartnerAccepted, and the events OnStarted, OnObjectAdded, OnAccepted, OnDeclined, OnReset, OnFailedToAddObject, OnCompleted, OnEnded (see Events). The trade actions are game.Actions.Trade*. |
| events | OnVitalChanged, OnPortalSpaceEntered, OnPortalSpaceExited, OnDeath, OnCombatModeChanged, OnEnchantmentsChanged, OnLevelChanged, OnVitaeChanged, OnTotalExperienceChanged, OnAvailableLuminanceChanged. |
Character filters are a name substring (always a name, even "Monster"), an ObjectClass number, or a function; these filter functions run as plain Lua and may sleep.
game.Actions#
AC does one use, cast or move at a time, so scripts queue actions and wait for them:
local a = await(game.Actions.ObjectUse(potion))
if not a.Success then print(a.Error, a.ErrorDetails) end
Every call is Kind(args... [, options] [, callback]): the options table and the callback may come in either order after the arguments. The callback gets the action when it finishes (as its own coroutine). Objects are WorldObjects or ids. Every call returns the action at once; it is already queued.
- One queue for all scripts, highest priority first, same priority in the order queued, one action at a time.
SleepandInvokeChatrun beside the queue at once. - Options:
{ Priority, TimeoutMilliseconds, MaxRetryCount, SkipChecks, Name }.Priorityis a number or an ActionType name ("Wield").TimeoutMillisecondscounts per attempt, 0 = none.SkipChecksskips the pre-checks and the wait for a free client. - How an action runs: it waits for the client to be free (not in portal space, no cast or use gesture playing; if that lasts past the timeout it fails TimedOut without being sent), checks its preconditions, sends the command, then watches real completion signals (the server's UseDone, the item moving, the appraisal arriving, the combat mode ...) and AC's failure messages in chat.
TooBusyandSpellFizzledare temporary: retried up toMaxRetryCountafter a short back-off. - On engine API v70+ the server's own codes decide: the UseDone's WeenieError code (0 = done), the WeenieError / WeenieErrorWithString refusals, and InventoryServerSaveFailed (which names its item).
ErrorDetailsthen names the code, e.g.the server said no (0x0402 YourSpellFizzled). Uses and casts only count refusals of their own kind (a cast: spell refusals and "too busy"; everything else: general ones, never spell or combat ones), so RynthAi fizzling or fighting beside a script no longer fails its action, and the chat lines those codes stand for ("You're too busy!", "Your spell fizzled.", ...) are ignored; "You cast ..." doesn't finish a CastSpell either (the UseDone does). Chat still decides the failures that only come as text ("Cannot use the X with the Y", "You must wield ...", "You have used this item too recently", pack space ...). Older engines: chat as before.
| Action | Arguments | Default priority, timeout | Done when / Result |
|---|---|---|---|
ObjectUse | obj [, target] | Misc, 10 s | UseDone, the item used up, portal space, or the container opened. |
ObjectUseOn (also ObjectApply) | obj, target | Misc, 10 s | As ObjectUse. (UB does use-on as ObjectUse(obj, target), which works here too; ObjectApply is RynthLua's.) |
ObjectGive | obj, target | Inventory, 10 s | The item leaves your inventory (or its stack shrinks), or "You give ...". |
ObjectMove | obj, container [, slot=0 [, stack=true]] | Inventory, 5 s (10 s for a pickup) | The item is in the container. With stack it merges into a matching stack there. Picks things up when they aren't yours. Result: the object (nil after a merge). |
ObjectSplit | obj, container, newStackSize [, slot] or obj, newStackSize | Inventory, 5 s | The new stack appears. Container 0 = the same pack. Result: the new stack. |
ObjectDrop | obj | Inventory, 5 s | The item isn't in your inventory any more. |
ObjectWield | obj [, slot] | Wield, 5 s | You wield it. Result: the object. slot is an EquipMask number (e.g. 0x00100000 melee weapon, 0x00200000 shield, 0x00400000 missile weapon, 0x01000000 held, 0x02000000 two-handed; rings and bracelets have a left and a right bit): on API v70+ the item goes into that slot, as a paperdoll drag does, and a slot the item doesn't fit (its ValidLocations, IntId 9, when known) fails InvalidInventoryLocation before sending. No slot, or an older engine: AC's default slot. |
ObjectSelect | obj | Misc, 5 s | It is the selection. Result: the object. |
ObjectAppraise | obj | Misc, 5 s | New appraisal data arrives. Result: the object. |
CastSpell | spellId [, target] | CastSpell, 5 s | UseDone or "You cast ...". Needs magic mode. Retries: 3. |
SetCombatMode | mode (number or name) | Combat, 5 s | The client reports the mode (at once when already in it). |
InvokeChat | text | Immediate | The chat parser took the line (as typed in the chat bar). Result: true. |
Sleep | milliseconds | Immediate, no timeout | The time has passed. |
RunAllOrdered | { action, ... } | Misc, no timeout | Every action in the list, in order; stops at the first failure (with its Error; ErrorDetails says the step), the rest are cancelled. The actions must be this script's; ones still queued are taken out of the queue, one already running is waited for. Result: the list. |
Blank | Misc | Does nothing and succeeds (a placeholder). | |
SetAutorun | enabled | Navigation | Autorun on or off; succeeds when the engine takes it. |
SendTellById | obj, message | Immediate | Sends /t <its name>, <message> through the chat parser. |
CastEquippedWandSpell | [target] | CastSpell, 5 s | Uses the wand, staff or orb you wield on the target (AC's way of casting its spell); UseDone. No caster wielded: InvalidSourceObject. |
SalvageAdd | obj | Inventory, 5 s | The item is in the salvage panel; opens the panel with an Ust from your inventory first when needed (NoUst when you have none). |
Salvage | Inventory, 10 s | Salvages what SalvageAdd put in the panel; done when those items are gone. Nothing added: NoActions. | |
VendorAddToBuyList | obj [, amount=1] | Immediate | Adds a vendor item to the buy list. VendorNotOpen, VendorDoesntHaveThisItem, VendorDoesntHaveEnoughOfThisItem. |
VendorAddToSellList | obj | Immediate | Adds one of your items to the sell list. |
VendorClearBuyList, VendorClearSellList | Immediate | Empties the list. Both lists are also emptied when the vendor closes. | |
VendorBuyAll, VendorSellAll | Vendor, 12 s | Sends the whole list as one transaction (engine API v67+); done when the server accepted it (the list is emptied when it is sent). Empty list: NoActions; no vendor: VendorNotOpen; refused: ServerError with the engine's reason. | |
TradeAdd | obj | Trade, 5 s | The item shows on your side of the trade window (engine API v72+); a refusal fails with its code. No trade open: NoTradePartner. |
TradeAccept, TradeDecline, TradeReset, TradeEnd | Trade, 5 s | You accepted / withdrew / the window emptied / the trade closed. | |
Login, Logout, SkillAdvance, AttributeAddExperience, SkillAddExperience, VitalAddExperience, FellowCreate, FellowDisband, FellowDismiss, FellowSetLeader, FellowQuit, FellowRecruit, FellowSetOpen, AllegianceSwear, AllegianceBreak, Inscribe | UB's | Not available yet: the call works and the action fails at once with Exception and an ErrorDetails saying it needs engine support. |
Default MaxRetryCount is 3 (0 for Sleep, InvokeChat, RunAllOrdered and the vendor, trade, salvage, tell and autorun actions).
Action object (a table whose fields are rewritten as it runs):
| Field | What |
|---|---|
ActionId, ActionType, Kind, Name, ScriptName | ActionType is UB's: the kind's priority category, a number (a.ActionType == ActionType.Inventory; Immediate for Sleep, InvokeChat and the other immediate ones); Kind is the function that made it ("ObjectUse"); Name the option or the kind. |
Priority, Options | The options in effect. |
IsStarted, IsRunning, IsFinished | |
Success, Error, ErrorDetails | Error is an ActionError name ("None" until it fails); ErrorDetails says what happened. |
Result | See the table above; nil otherwise. |
StartedAt, FinishedAt | clock() milliseconds (nil until then). |
CurrentRetryCount | |
Cancel(), Await() | Cancel it (Error "Cancelled"); a.Await() is await(a). |
| per kind | ObjectId, TargetId (object actions; TargetId is the container for Move and Split); Slot, Stack (Move); NewStackSize, Slot, and when done NewStackObjectId (Split); Slot (Wield); SpellId, TargetId (CastSpell); CombatMode, CombatModeName (SetCombatMode); Milliseconds (Sleep); Text (InvokeChat); Actions (RunAllOrdered); ObjectId, Message (SendTellById); TargetId (CastEquippedWandSpell); ObjectId, Amount (vendor lists); Enabled (SetAutorun). |
Errors RynthLua reports (the ActionError global has UB's full list; these are the ones that can happen):
| Error | When |
|---|---|
TimedOut | No completion signal within the timeout, or the client stayed busy that long. |
NotLoggedIn | Not in game (Sleep, InvokeChat and RunAllOrdered don't need it). |
InvalidSourceObject | The object isn't known to the client. |
SourceItemNotInInventory | Give, Split or Drop of something that isn't yours; "You must wield/contain the ... to use it". |
InvalidTargetObject | The target isn't known, isn't someone to give to, or "You must specify a target". |
CantUseOnItself | Use-on with the object as its own target, or "cannot be combined with itself". |
InvalidTargetItem | "Cannot use the X with the Y" / "The X cannot be used on ...". |
TargetItemNotInInventoryOrLandscape | ObjectMove's container isn't known. |
InvalidInventoryLocation | ObjectMove without a container, the engine refused the move, no pack space, the server refused the slot (API v70+), or an ObjectWield slot the item doesn't fit. |
CantSplitThisObject, ObjectSplitAmountTooBig | Not a stack; the new stack isn't smaller than the stack. |
ItemAlreadyWielded | ObjectWield of something you wield. |
NotTrained, ItemBeingTraded, UnsalvageableItem, YouDoNotPassCraftingRequirements, YouHaveBeenInPKBattleTooRecently | The server refusal of that name (API v70+ codes). |
InvalidCombatMode | CastSpell outside magic mode. |
YouDontKnowThatSpell, UnknownSpellId, MissingComponents, SpellFizzled | Casting. |
TooBusy | "You're too busy!" (retried). |
SourceObjectTooFar | "Unable to move to object". |
TooEncumbered, YouCantPickThatUp, MustBeInPeaceMode, OnCooldown, NPCDoesntKnowWhatToDoWithThat | AC's messages of those names. |
ServerError | Other refusals: "is not accepting", out of range, not enough mana, "You fail to affect"; on API v70+ also any UseDone code RynthLua has no name for (ErrorDetails has the number). |
VendorNotOpen, VendorDoesntHaveThisItem, VendorDoesntHaveEnoughOfThisItem | The vendor actions. |
NoTradePartner | A trade action with no trade open. |
NoUst, NoActions | SalvageAdd without an Ust; Salvage with nothing added, a Vendor*All with an empty list. |
Exception | The engine didn't accept the command (missing SDK function, bad id), a Lua-side error, or an action that needs engine support (see the table). |
Cancelled | Cancel(), ActionQueue.Remove/Clear, the script stopped, logout, or a RunAllOrdered that stopped. |
PreconditionFailed | A RunAllOrdered item that had already failed without an Error. |
game.ActionQueue#
| Member | What |
|---|---|
Queue | Running and waiting actions (all scripts), in run order. |
ImmediateQueue | Running Sleep / InvokeChat actions. |
Count | Everything live (both lists). |
Current | The action holding the slot, or nil. |
IsBusy | An action holds the slot. |
Contains(action) | Queued or running. |
Add(action) | Actions are queued when made; returns whether this one still is. |
Remove(action) | Cancels one of this script's actions; true when it was live. Another script's is an error. |
Clear() | Cancels all of this script's actions; returns how many. |
Another script's actions show as summary tables: { Name, ActionType, Kind, Priority, ScriptName, IsStarted, IsRunning, IsFinished = false }.
Modules (require)#
json: json.encode(value [, pretty]), json.decode(text) (also Encode/Decode). A table with keys exactly 1..n is an array (an empty table is []), any other table an object; a WorldObject encodes as its Id, a typed enum value as its number. Functions, coroutines, NaN/infinity and tables that contain themselves are errors that say where. JSON null decodes to nil. Nesting limit 200. Also the names of the JSON module UB's interpreter ships: json.parse(text) (like decode, but JSON null becomes json.null(), so arrays keep their holes), json.serialize(value) (encode), json.null() (the null value; encodes as null, prints "null") and json.isnull(v) (true for nil and json.null()).
storage: this script's saved values, as JSON in Data\<Name>\storage.json.
| Function | What |
|---|---|
storage.Get(key [, default]) | The value, or default (nil). |
storage.Set(key, value) | Any JSON-able value; nil removes the key. |
storage.Remove(key) | True when it was there. |
storage.Has(key), storage.Keys() (sorted), storage.Clear() | |
storage.Save() | Write now (false when the write failed). |
storage.Character | The same functions for the logged-in character (Data\<Name>\characters\<server>_<character>.json); an error before login. |
Values are copies: Set stores the value as it is then, Get returns a fresh table. Keys are text (numbers are turned into text), 1 to 512 characters. Writes happen within about 2 s of a change, and when the script stops; a file that can't be read is kept as .unreadable and the store starts empty.
enums: the enum tables (also globals in every script), with UtilityBelt's names and numbers: ObjectClass, SkillId, AttributeId, VitalId, CombatMode, IntId, BoolId, StringId, ChatType (also ChatMessageType), ClientState, and every enum in LuaEnumData.cs: AmmoType, AttackHeight, CharacterOptions1, CharacterOptions2, ContainerProperties, CoverageMask, CreatureType, DamageType, DataId, EnchantmentFlags, EndTradeReason, EquipMask, FloatId, Gender, HeritageGroup, IconHighlight, InstanceId, Int64Id, MagicSchool, MaterialType, MotionStance, ObjectDescriptionFlag, ObjectType, PhysicsState, PlayScript, RadarBehavior, RadarColor, SkillTrainingType, SpellCategory, SpellFlags, SpellType, TradeSide, UsableType, Vital, WeenieError, WeenieType, WieldType, and UB's scripting enums AddRemoveEventType, BusyAction, CastEventType, ChatChannel, ClientCapability, ClientConfirmationType, DistanceType, FellowshipEventType, ScriptStartupType, UseActionType.
Most enums are plain numbers both ways: SkillId.MeleeDefense == 6 and SkillId[6] == "MeleeDefense"; names also match in any case (SkillId.meleedefense). Numbers have UB's enum methods: SkillId.Axe:ToNumber(), EquipMask.Head:HasFlags(...), :AddFlags(...), :RemoveFlags(...) (indexing a number with anything else is still an error).
Typed enums: Int64Id, FloatId, StringId, BoolId, DataId, InstanceId and ObjectType values are typed (one table per value per script), so wo:Value(key) can tell a string id from an int id with the same number and World.GetAll(ObjectType.X) from an ObjectClass. A typed value prints as its name (tostring(StringId.Name) is "Name"; combined flags "Creature, Misc"), compares and orders with values of its enum (not with plain numbers: StringId.Name == 1 is false, as with UB's enum userdata), adds and subtracts as a number, concatenates as its name, has ToNumber(), HasFlags, AddFlags, RemoveFlags, and is accepted wherever a number is. Its number is :ToNumber(); reverse lookup (StringId[1] == "Name") still works. IntId stays plain numbers (a plain number key means an IntId).
ClientState values are the texts game.State returns (ClientState.In_Game == "InGame", Character_Select_Screen == "CharacterSelect", Logging_Out == "LoggingOut"), like ActionError. A script that assigns something else to a global name (SkillId = nil) doesn't change what require("enums") returns.
ObjectClass: Unknown 0, MeleeWeapon, Armor, Clothing, Jewelry, Monster 5, Food, Money, Misc, MissileWeapon, Container 10, Gem, SpellComponent, Key, Portal 14, TradeNote, ManaStone, Plant, BaseCooking, BaseAlchemy, BaseFletching 20, CraftedCooking, CraftedAlchemy, CraftedFletching, Player 24, Vendor, Door, Corpse 27, Lifestone, HealingKit, Lockpick 30, WandStaffOrb, Bundle, Book, Journal, Sign, Housing, Npc 37, Foci, Salvage, Ust 40, Services, Scroll 42 (Decal / UB order), and UB'sNumObjectClasses43.SkillId: AC's numbers, Axe 1 ... Summoning 54 (WarMagic 34, LifeMagic 33, MeleeDefense 6, ...),Undef0, and UB's spellingsThrownWeapons12,ArmorRepair26,MissleWeapons47 besidesThrownWeapon,ArmsAndArmorRepair,MissileWeapons.AttributeId: Undef 0, Strength 1, Endurance 2, Quickness 3, Coordination 4, Focus 5, Self 6.VitalId: Health 1, Stamina 3, Mana 5 (UB's numbering, AC's max-vital ids).CombatMode: NonCombat 1, Melee 2, Missile 4, Magic 8, Invalid 153.IntId,BoolId,StringId: AC's property ids with ACE's names (IntId.Value19,IntId.StackSize12,BoolId.Attackable19,StringId.Name1, ...), plus UB's aliasesIntId.ObjectType= 1 (ItemType),IntId.MerchandiseObjectTypes= 74,IntId.HookObjectType= 152.ChatType: Default 0, Speech 2, Tell 3, OutgoingTell 4, System 5, Combat 6, Magic 7, Channels 8, OutgoingChannel 9, Social 10, OutgoingSocial 11, Emote 12, Advancement 13, Abuse 14, Help 15, Appraisal 16, Spellcasting 17, Allegiance 18, Fellowship 19, WorldBroadcast 20, CombatEnemy 21, CombatSelf 22, Recall 23, Craft 24, Salvaging 25, AdminTell 31.
rynth.ai: RynthAi through its script interface. Everything except Available and Command raises "RynthAi isn't loaded ..." without RynthAi, so check ai.Available first or use pcall.
| Member | What |
|---|---|
Available (also IsLoaded) | RynthAi is there. |
Evaluate(expr) | A meta expression; numbers come back as numbers. |
GetSetting(name) | Number, boolean or text; nil for an unknown setting. |
SetSetting(name, value) | True, or false for an unknown setting. Saves the profile. |
SettingNames() | Every setting name, sorted. |
MacroRunning | Read, or assign true/false to start or stop the macro. |
GoTo(ns, ew) | Walk there (numbers with S/W negative, or "33.5N" / "44.8W"). |
Stop() | Stop navigation (and the macro). |
FindNearest(name [, portalsOnly]) | The nearest object whose name contains name, and its distance: local wo, d = ai.FindNearest("Portal", true); nil when none. portalsOnly means portals and NPCs. |
DistanceTo(target) | Metres, -1 when unknown; target is an object, id or name. |
IsPathClear(target) | Line of sight; target is an object, id or name. |
Command(text) (also SubmitCommand) | A chat line as if typed (/ra, /vt, ...); without RynthAi it goes to AC's own parser. |
filesystem: UB's shape, for scripts that keep their own files.
require("filesystem").GetData(): the script's data folder (Data\<Name>\), read and write.require("filesystem").GetScript(): the script's own folder, read-only (folder scripts only).GetCustom()isn't available (an error).
The returned object has IsApproved (true), IsReadOnly, and ReadText(file), ReadLines(file), WriteText(file, text), AppendText(file, text), FileExists(file), DirectoryExists([dir]), CreateDirectory(dir), DeleteFile(file), GetFiles([dir]), GetDirectories([dir]) (names relative to the folder, sorted). Every call returns its result and an error message: local text, err = fs.ReadText("notes.txt") gives nil and the reason on failure (writes give false). Paths are relative and can't leave the folder (no drive letters, no leading slash, no .. out of it, no device names). Reads stop at 64 MB. WriteText replaces the file atomically.
rynthlua: { Name = "RynthLua", Version, ScriptName, ScriptFolder, DataFolder } (ScriptFolder nil for single-file scripts).
views and imgui: script windows, below.
Script windows (views, imgui)#
A script can draw its own windows ("huds"): trackers, settings forms, lists with buttons. The code is immediate-mode ImGui in UtilityBelt's shape:
local views = require("views")
local ImGui = require("imgui") -- require("imgui").ImGui is the same table
local hud = views.Huds.CreateHud("Hello")
hud.Visible = true
local clicks = 0
hud.OnRender.Add(function()
ImGui.Text("Hello, " .. game.Character.Name)
if ImGui.Button("Click me") then clicks = clicks + 1 end
ImGui.SameLine()
ImGui.Text(clicks .. " click(s)")
end)
How it works.
- While a hud is shown, its
OnPreRenderandOnRenderhandlers run together as one pass, on the plugin thread, about 20 times a second (hud.RefreshRate). EachImGui.X(...)call records one item; Lua never draws. The engine draws the latest recording every frame, so the window moves, scrolls, highlights and takes typing at the full frame rate. - What the player does comes back one pass late: a click makes
ImGui.Buttonreturn true on the hud's next pass, a changed checkbox makesImGui.Checkboxreturntrue, newValue. A pass runs on the tick after any input whatever the refresh rate, so this is about one tick plus one frame. - ImGui calls only work inside a pass; anywhere else they raise "ImGui calls only work inside a hud's OnRender". The metric queries (
GetTextLineHeight,GetTextLineHeightWithSpacing,GetFrameHeight,GetStyle,CalcTextSize) work any time. - A pass can't
sleeporawait("sleep/await can't be used in OnRender; use spawn"). Gather slow data in aspawned thread and letOnRenderdraw what it has. Game reads insideOnRenderare fine. - Script windows need engine API v71 with the ImGui layer on.
views.Availablesays whether they can show. On an older engine, or with ImGui off, huds can still be created and the script runs normally, but nothing shows; the script's console says so once. - A hidden hud runs no passes. A script's huds close when it stops.
views
| Member | What |
|---|---|
views.Huds.CreateHud(name [, icon]) | This script's hud called name. A second call with the same name returns the same hud. icon is accepted and ignored. At most 8 huds per script and 32 across RynthLua; more is an error. The window's saved place ignores case, and =, , and # count as _, so a name that differs from another hud's only that way ("Main" and "main") is an error too. |
views.Available | True when script windows can show (engine API v71, ImGui on). Checked again at most once a second. |
views.Huds.GetIconTexture(iconId) | A texture for an AC icon, for ImGui.Image / ImageButton (UB's name). An id below 0x06000000 gets 0x06000000 added, as in UB. See "Icons" below. |
views.Huds.GetObjectIconTexture(obj) | An item's picture as AC shows it: its icon over its underlay, with its overlay on top. obj is a world object or an object id. RynthLua extra. |
views.Huds.GetSpellIconTexture(spell) | A spell's icon; spell is a spell id or a table with an Id. RynthLua extra. |
views.Huds.CreateTexture(file) | An error: RynthLua windows draw AC icons only, not image files. |
Hud members
| Member | What |
|---|---|
Name | Read-only. |
Title | The header text (default, and nil: the name). |
Visible | Read or write. Starts as the player's last choice for this hud on this character, otherwise false (see "Open or closed" below). The window's X, the bar's Scripts menu and /lua hud change it too. |
ShowInBar | Listed in the bar's Scripts menu (default true). |
NoPopOut | No ↗ button: the window can't pop out of the game window (default false). Set while it is popped out, the window goes back into the game window. |
WindowSettings | ImGuiWindowFlags, the whole set at once (details below). Default 0. |
Chrome | "standard" (the RynthCore frame, the default) or "none" (no header or grip, for bare HUDs); any case. Anything else, nil included, is an error. |
DefaultSize | A Vector2 (or {x, y}): the size used while nothing is saved for this window yet. Same as SetNextWindowSize(size, ImGuiCond.FirstUseEver). nil = the engine default (300 x 200). |
RefreshRate | Passes per second while shown: rounded, then kept within 1 to 60. nil = 20. Not a number is an error. A new rate starts at once. |
LastError | Read-only. The last pass's error, or nil once a pass works again. |
IsDisposed | Read-only. True after Dispose() or when the script stopped. |
OnPreRender, OnRender | Events (Add / Once / Until / Remove). Both run in the same pass, OnPreRender first; it is where UB scripts call SetNextWindowSize and friends. Handlers get no arguments. |
OnShow, OnHide | Events, {}: the hud was shown or hidden, by anyone (the script, the player, /lua hud). They run as their own threads, so they may sleep. There is none at CreateHud, even when the hud starts shown. |
Dispose() | Removes the hud; its window closes. The window's saved place is kept. |
Any other key is the script's own field (hud.count = 0 works).
WindowSettings. Each assignment replaces the whole set. Honoured:NoTitleBar(the same asChrome = "none"),NoInputsorNoMouseInputs(click-through: the window lets clicks through to the game),NoBackground,NoScrollbar,NoScrollWithMouse.NoNavInputs,NoNavFocusandNoCollapseare accepted quietly. Any other flag (AlwaysAutoResize,NoResize,NoMove,MenuBar, ...) is ignored with one console line per hud naming it. The value must be a whole number from 0 to 4294967295; nil means 0. Reading it gives the last value set.ChromeandNoTitleBarare one switch: whichever was set last wins.- A pass right away (on the next tick, whatever the rate): after input to the window, when the hud is shown, and after
Title,ChromeorWindowSettingschange. Other passes keep toRefreshRate.
The window. Script windows get the RynthCore panel frame: a header you drag, a close X and a resize grip. hud.Chrome = "none" leaves out the header and grip. The engine saves each window's place and size under RynthLua/<script>/<hud>, so a restarted script's window comes back where it was. Sizes and positions are in UI units; the engine scales them with RynthCore's UI scale.
Popping out. A framed window has the ↗ button in its header, like the engine's panels: it pops out of the game window into a window of its own that you can put anywhere, a second monitor included, and the same button (now ↙) puts it back where it was docked. Everything in it works popped out: buttons, checkboxes, sliders, text boxes, trees, tooltips and AC icons. The window remembers being popped out and where: closed, reloaded or restarted, it opens popped out again at that spot. hud.NoPopOut = true leaves out the ↗. A bare window (Chrome = "none", or NoTitleBar in WindowSettings) never pops out: it has no header for the button and is meant to sit over the game; one that turns bare while popped out goes back into the game window. Popped out, ImGui.GetWindowPos() is the window's place on its monitor (from the top-left of the monitor's work area), not in the game window, and a click-through window takes clicks (it is its own window). You move and size a popped-out window yourself: SetNextWindowSize / SetNextWindowPos apply once it is back in the game window.
The bar. While any hud with ShowInBar exists, the RynthCore bar has a Scripts button (tooltip "Script windows"). Its menu lists those huds under their script's name, with a check on the open ones. Picking one shows or hides it, as the player's own choice.
Open or closed (per character).
- The player's choices are remembered: the window's X, the bar's menu and
/lua hud show|hide|toggle. They are kept per character and per hud inhud_visibility.json, written about 2 s after a change and at logout. - When a script creates a hud, it starts shown if the player last left it open on this character, otherwise hidden.
- The script's own
hud.Visible = ...always applies and is not remembered. So a script that setshud.Visible = trueat start always opens its window; leave that out to let the player's last choice decide. - Before login nothing is remembered or recalled (huds start hidden).
- The memory applies when a hud is created. A "global" autostart script keeps running across a character change, and its huds stay as they were.
- At most 500 huds per character are remembered; the oldest choices go first.
Errors.
- An error in
OnPreRenderorOnRenderends that pass. So does going over the instruction cap (200,000 Lua instructions per pass), orsleep/await. The window keeps its last good picture with the error in red above it,hud.LastErrorhas the text, and the script's console gets it (the same hud at most once every 5 s). The next good pass clears it. - After 20 failed passes in a row the hud stops running passes, and the console says so. Hide and show it again (a real hide then show, by the script, the player or
/lua hud), or restart the script, to try again. - Mistakes are errors with plain messages:
PopID()without aPushID(),EndChild()orTreePop()that doesn't match,PopStyleColor(n)popping more than was pushed, nesting deeper than 32, more than 1,500 items, an unsupported function (ImGui.PlotLines isn't supported by RynthLua windows yet), a bad argument. - Warnings, once per hud: scopes left open at the end of the pass (a missing
EndChild,TreePop,PopIDorPopStyleColor; they are closed for you), and two widgets with the same ID (add##somethingto one label, or usePushID).
Limits.
| Limit | Value | When hit |
|---|---|---|
| Huds | 8 per script, 32 in RynthLua | CreateHud raises an error. |
| Items per hud | 1,500 | The pass fails ("drew more than 1500 items"); the last good picture stays. |
| Recording size per hud | 64 KB | The same ("drew more than 64 KB"). |
| Changed pictures sent at once | 256 KB, all huds together | The ones that don't fit are sent on the next tick (a few ticks at most). |
| One text | 4 KB | Cut (on a whole character). |
InputText length | maxLen bytes, 1 to 4096 (default 256) | The text is cut to it. |
Combo items | 512 | The rest are left out. |
Nesting (child regions, open trees and PushIDs) | 32 | The pass fails. |
| Lua instructions per pass | 200,000 | The pass is stopped and counts as an error. |
| Passes, all huds together | 1.5 ms per tick | The rest wait for the next tick. |
| Engine drawing, all script windows | 4,000 items a frame | Windows past it show "Too large to draw this frame." |
imgui
Names, argument order and defaults follow ImGui.NET 1.91 (what UB scripts call). Values ImGui.NET passes by ref come back as extra return values: changed, v = ImGui.Checkbox("x", v). ImGui.X(...) and ImGui:X(...) both work.
| Function | Returns | Notes |
|---|---|---|
Text(...) | Every argument is turned into text and joined: ImGui.Text("HP ", hp). Never a format string. | |
TextColored(col, ...) | col: a colour (below). | |
TextWrapped(...), TextDisabled(...), BulletText(...), SeparatorText(...) | ||
LabelText(label, ...) | ||
Separator(), NewLine(), Spacing() | ||
SameLine([offset [, spacing]]) | Defaults 0 and -1 (the style's spacing). | |
Dummy(size) | nil = (0, 0). | |
Indent([w]), Unindent([w]) | 0 or nil = the style's indent. | |
Button(label [, size]) | clicked | size nil or (0, 0) = fit the label; -1 = fill. Several clicks come one per pass. |
SmallButton(label) | clicked | |
Checkbox(label, v) | changed, v | |
SliderInt(label, v [, min [, max [, fmt]]]) | changed, v | Defaults 0, 100, "%d". min > max are swapped; v is kept in range. |
SliderFloat(label, v [, min [, max [, fmt]]]) | changed, v | Defaults 0, 1, "%.3f". Unchanged, v comes back exactly as given. |
InputText(label, text [, maxLen [, flags]]) | changed, text | maxLen in bytes (default 256). The text follows every edit; with ImGuiInputTextFlags.EnterReturnsTrue only changed waits for Enter. |
Combo(label, index, items [, count]) | changed, index | index is 0-based, as in ImGui.NET (-1 = none); items is a Lua list (1-based) or ImGui's "a\0b\0c\0" text. count limits how many of the list are used (the text form ignores it). |
Selectable(label [, selected [, flags [, size]]]) | clicked, selected | The second value is selected flipped when clicked (UB's ref form); if ImGui.Selectable(...) then works too. |
InputInt(label, v [, step [, stepFast [, flags]]]) | changed, v | A number box with - and + buttons. Defaults 1 and 100 (0 = no buttons). With EnterReturnsTrue the value changes on Enter. |
InputFloat(label, v [, step [, stepFast [, fmt [, flags]]]]) | changed, v | Defaults 0, 0 (no buttons), "%.3f". Unchanged, v comes back exactly as given. |
DragInt(label, v [, speed [, min [, max [, fmt [, flags]]]]]) | changed, v | Drag left and right to change it (or double-click to type). Defaults 1, 0, 0, "%d"; min equal to max means no limits. flags: ImGuiSliderFlags. |
DragFloat(label, v [, speed [, min [, max [, fmt [, flags]]]]]) | changed, v | Defaults 1, 0, 0, "%.3f". Unchanged, v comes back exactly as given. |
Image(texture [, size [, uv0 [, uv1 [, tint [, border]]]]]) | An AC icon. texture from views.Huds.Get*IconTexture (or its TexturePtr), or an icon id number. size nil = 32 x 32 (AC's icon size). uv0/uv1 default (0, 0) and (1, 1); tint default white, border default none. | |
ImageButton(id, texture [, size [, uv0 [, uv1 [, bg [, tint]]]]]) | clicked | A button showing an icon. id is the button's ID (not shown; use "##name"-style ids for rows, or PushID). |
ProgressBar(fraction [, size [, overlay]]) | fraction 0 to 1; size default (-1, 0) = the full width; no overlay = ImGui's percentage. | |
BeginChild(id [, size [, border [, windowFlags]]]) | true | border is a boolean or ImGuiChildFlags (Borders). Always call EndChild(). |
EndChild() | ||
CollapsingHeader(label [, flags]) | open | The contents follow as ordinary calls: if ImGui.CollapsingHeader("More") then ... end. The (label, visible) form is an error. |
TreeNode(label [, flags]) | open | Call TreePop() only when it returned true. NoTreePushOnOpen is an error. |
TreePop() | ||
PushID(id), PopID() | id: text or a number (object ids work). | |
PushStyleColor(which, col), PopStyleColor([n]) | which: an ImGuiCol value or name. Allowed: Text, TextDisabled, ChildBg, Border, FrameBg, CheckMark, SliderGrab, Button, ButtonHovered, ButtonActive, Header, HeaderHovered, PlotHistogram; others are an error. n defaults to 1. | |
SetItemTooltip(...) | A tooltip for the item before it, shown on hover (by the engine, no delay). | |
SetNextWindowSize(size [, cond]) | See "Window calls". | |
SetNextWindowPos(pos [, cond [, pivot]]) | pivot is accepted and ignored. | |
SetNextWindowSizeConstraints(min, max) | Only min is used (it stays until changed); max is ignored. | |
GetWindowSize(), GetWindowPos(), GetContentRegionAvail() | Vector2 | Last frame's, inside a pass only; (0, 0) until the engine first reports them. |
GetTextLineHeight(), GetTextLineHeightWithSpacing(), GetFrameHeight() | number | Any time. |
GetStyle() | { ItemSpacing, FramePadding } | Any time; other style fields are an error. |
CalcTextSize(text [, hideAfterDoubleHash [, wrapWidth]]) | Vector2 | Any time. Exact for plain ASCII with the default font, an estimate for other characters. wrapWidth is ignored. |
SetClipboardText(text) | ok | Any time. Puts text on the Windows clipboard (numbers and other values as tostring shows them). ok is false when another program kept the clipboard busy. |
GetClipboardText() | text | Any time. The clipboard's text, "" when it holds none. |
Any other name raises "ImGui.X isn't supported by RynthLua windows yet".
- Labels and IDs work as in ImGui:
"Go##2"shows "Go" with its own ID,"###id"makes only what follows the ID, andPushID/PopID(and open trees and child regions) give the widgets inside their own IDs, so rows of the same buttons needPushID(row.id). - Sizes are a
Vector2,{x, y},{X =, Y =}or{x =, y =}; nil is (0, 0) and anything else is an error. As in ImGui, 0 means automatic and -1 means fill. - Colours are a
Vector4with 0 to 1 components (Vector4.new(1, 0, 0, 1)is red), or a0xAABBGGRRnumber. - Flags are only the ones the engine can draw safely. Anything else is dropped without an error. InputText:
CharsDecimal,CharsHexadecimal,CharsUppercase,CharsNoBlank,EnterReturnsTrue,ReadOnly,Password,AutoSelectAll. Selectable:AllowDoubleClick,Disabled,AllowOverlap. TreeNode and CollapsingHeader:Selected,Framed,AllowOverlap,DefaultOpen,OpenOnDoubleClick,OpenOnArrow,Leaf,Bullet,FramePadding,SpanAvailWidth,SpanFullWidth,SpanTextWidth. BeginChild's window flags:NoScrollbar,NoScrollWithMouse,NoBackground,HorizontalScrollbar,AlwaysVerticalScrollbar,AlwaysHorizontalScrollbar. InputInt and InputFloat:EnterReturnsTrue,ReadOnly,AutoSelectAll,ParseEmptyRefVal,DisplayEmptyRefVal. DragInt and DragFloat (ImGuiSliderFlags):AlwaysClamp(ClampOnInput,ClampZeroRange),Logarithmic,NoRoundToFormat,NoInput,WrapAround. Slider, drag and InputFloat formats may hold one number conversion (%d,%.2f, ...) and%%; any other format falls back to the default. - Needs a newer engine.
Image,ImageButton,InputInt,InputFloat,DragIntandDragFloatneed an engine from 2026-09-30 or later (script windows "op level 2"). On an older engine they raise an error saying so, rather than silently drawing nothing. - Window calls (
SetNextWindowSize,SetNextWindowPos), bycond:ImGuiCond.FirstUseEver: a default, used only while nothing is saved for the window.Appearing: on the first pass after the hud is shown.Once: until the hud's first good pass.- none or
Always: every pass, so the window keeps being put back while the script asks.
Icons.
local views, ImGui = require("views"), require("imgui")
local hud = views.Huds.CreateHud("Pack")
hud.OnRender.Add(function()
for _, wo in ipairs(game.Character.Inventory) do
ImGui.Image(views.Huds.GetObjectIconTexture(wo), Vector2.new(24, 24))
ImGui.SameLine()
ImGui.Text(wo.Name)
end
end)
- A texture names an icon; it isn't a picture the script owns.
GetIconTexture(id)is an icon by its id (the0x06...number, whatwo:Value(DataId.Icon)gives);GetObjectIconTexture(obj)is an item as AC draws it (underlay, icon, overlay: the overlay follows changes within about 2 s);GetSpellIconTexture(spell)a spell's icon. The same call returns the same texture table, so calling them insideOnRenderis fine. - The texture's fields:
TexturePtr(the texture itself, so UB'sImGui.Image(tex.TexturePtr, size)works),Kind("icon","object","spell"),Id, andDispose()/Release(), which do nothing (the engine owns the pictures). UB'sBitmapandTexturefields raise an error. - The engine reads the pictures from
client_portal.datin the background and keeps the last 256 it drew. Until one is ready (usually the next frame or two), or when it can't be found (a bad id, an object the game hasn't sent, noclient_portal.dat), a dim square of the same size is drawn instead. A missing icon is never an error.
Vector2, Vector4 and the ImGui enums (globals in every script).
Vector2.new(x, y)orVector2(x, y);Vector4.new(x, y, z, w)orVector4(...). One number fills every component.Vector2.Zero,Vector2.One,Vector4.Zero,Vector4.Oneare fresh values each time.- Fields
X,Y(Z,W), also asx,y,z,w.+,-,*,/work with another vector (per component) or a number; unary-,==andtostring("Vector2(1, 2)") too. ImGuiWindowFlags,ImGuiCond,ImGuiCol,ImGuiTreeNodeFlags,ImGuiInputTextFlags,ImGuiSelectableFlags,ImGuiChildFlags,ImGuiSliderFlags: ImGui.NET 1.91.6.1's names and values, as plain two-way tables like the other enums (ImGuiCond.FirstUseEver == 4,ImGuiWindowFlags[43] == "NoDecoration", names in any case). Combine flags with+(each once) orbit32.bor.
v1 API#
Kept exactly as it was in RynthAi. Meta expressions, settings, the macro and navigation come from RynthAi and raise an error when it isn't loaded.
| Global | What |
|---|---|
chat(...) | To your own chat window. |
command(...) | A line as if typed in chat (/ra, /ub, /mt, /say, /f, ...). |
expr(expression) | A meta expression: expr("getcharvital_current[1]"). |
meta.<function>(args...) | Any meta expression function by name: meta.wobjectfindininventorybyname("Pyreal"). |
getvar(name), setvar(name, value) | Meta session variables, shared with metas. |
me.name, me.id, me.health, me.maxhealth, me.stamina, me.maxstamina, me.mana, me.maxmana, me.landcell, me.coords | Read live. |
RynthAi:GoTo(ns, ew), :Stop(), :UsePortal(name), :GetDistance(name), :GetPlayerNS(), :GetPlayerEW(), :GetPlayerZ(), :IsPathClear(target) | Colon calls. |
Settings.<name> | Read or assign any RynthAi setting metas can use. |
function OnBotTick() end | Called every 250 ms while the RynthAi macro runs. |
on(event, fn), off(event [, fn]) | v1 events, fn gets plain arguments (below). |
v1 events: login, logout, chat(text, chatType), target(currentId, previousId), combatmode(current, previous), objectcreated(id), objectdeleted(id), health(targetId, ratio, current, max), damagedealt(damage, type, crit), damagetaken(damage, type, crit), kill(text), enchantmentadded(spellId, seconds), enchantmentremoved(enchantmentId), vendoropen(vendorId), vendorclose(vendorId).
Commands#
| Command | What |
|---|---|
/lua list | Every script, with [running] and [auto:global/character]. |
/lua start <script> (also run) | Start, or restart when running. |
/lua restart <script> | The same. |
/lua stop <script>, /lua stop all (or /lua stop) | |
/lua exec <code> | Run code as a throwaway script called exec. |
/lua execin <script> <code> | Run code inside a running script's state (its globals), as a new thread. |
/lua autostart <script> none|global|character | "character" needs a logged-in character. |
/lua hud list | Every script window: script/hud, with [shown], [error] and [not in bar]. |
/lua hud show|hide|toggle <script>/<hud> | Show or hide a window, as the player would (remembered for this character; OnShow/OnHide fire). The hud's name alone works when only one hud has it. Any case. |
/lua hud bench <n>, /lua hud bench off | A test window with n widgets (1 to 1500) for measuring; timings go to the RynthCore log about every 10 s. |
Script names match in any case, with or without .lua. RynthAi's /ra lua ... (typed or from a meta) forwards here: /ra lua start MyScript.
Panel#
The ImGui Lua face: the script list (running state, autostart, description; unsaved editor and /lua exec scripts show as "(not saved)"), the selected script's console, start / stop / restart, autostart, the editor (load and save single-file scripts and folder scripts' index.lua; delete keeps a .bak), and an input line that runs code in the selected script.
Known limits#
Not built, or limited by what the engine offers today:
- Actions the engine can't do yet exist but fail at once (
Exception, ErrorDetails says why):Login,Logout,SkillAdvance,AttributeAddExperience,SkillAddExperience,VitalAddExperience, theFellow*actions,AllegianceSwear/Break,Inscribe. ObjectWield's slot needs engine API v70+; on older engines it uses the item and AC wields it in its default slot. Vendor actions need API v67+, trade v72+.CastSpell's "do you know it" pre-check uses the spellbook snapshot (re-read at most every 3 s); until the first snapshot after login it is skipped and an unknown spell fails on AC's message instead.- Completion signals: on an engine without the UseDone counter, uses and casts finish on a heuristic (the gesture ended and nothing complained). Before API v70 failures come from AC's chat lines, so another action's "You're too busy!" or fizzle (RynthAi, the player) can fail a script's action.
- Server codes (v70+): the engine keeps only the latest UseDone and the latest refusal, and neither says which action it answers. A UseDone for somebody else's action that lands first still finishes a script's use or cast, and of two refusals within one tick only the second is seen.
SalvageAddcan't see what is in the salvage panel: it counts an item as added when the panel takes it, andSalvagewaits for those items to disappear.- Only the running queue action hears AC's chat messages; an immediate action doesn't.
game.OnScriptEndhandlers run directly (not as coroutines), so they can'tsleeporawait. They run when the script is stopped or callsstop(), not when it fails to load.- game.World only knows objects it has seen (created since load, your inventory, the engine's object snapshot on API v69+, ids looked up directly).
- ObjectClass: Plant, CraftedCooking, Bundle, Journal, Sign and Housing exist in the enum but are never assigned. A fresh object may read Unknown until its data arrives.
Position.NS/EWcome from the landblock; inside dungeons they aren't map coordinates.- WorldObject: no whole-property dictionaries (
IntValues,StringValues, ...; the engine can read one property, not list them), noObjectDescription,PhysicsDesc,CreateFlags,Stance,LastAccessTime,CreatedAt,LastAppraisalResponse,CooldownTimeoutMilliseconds,IsOnSharedCooldown();Value(InstanceId.X)knows Container and Wielder only; other objects'Vitals/Skillsare empty;SpellIds/EnchantmentIdsentries have noLayer. - Chat: incoming lines can't be eaten (
Eatis always false; the engine delivers them after AC showed them).OnChatInputruns a tick later, so eating works from the second line of a command on (see Events);game.RegisterCommandeats from the first. Channel, fellowship and local lines are recognised from their text;OnEmotehas no sender and can't tell a soul emote from an emote. NoOnSoulEmote,OnChatNameClicked,OnConfirmationRequest. - Character events are polled: vitals and portal space every tick, vitae every 500 ms; level, experience and luminance every 500 ms and only while a script listens. Enchantments: on API v70+ from the engine's events (plus a re-read every 10 s), on older engines every 500 ms; only while a script listens.
OnDeathis inferred (health reaching 0, vitae dropping, or a death line in chat), once per 30 s; health and vitae are ignored for the first 10 s after login;Textis "" when no death line came;KillerIdis always 0.- Enchantments:
Durationis only known for ones added while RynthLua was running; names need RynthAi; the spellbook is re-read at most every 3 s. Events are per spell id: a second layer of a spell that is already on (or one of two layers going away) is aRefreshedAdded, or nothing, not a separate enchantment. No layers, no inactive (AllEnchantments()is the same list asActiveEnchantments()), noGetActiveEnchantments(stat)or enchantment modifiers. - Character: no
Fellowship,Allegiance,AnimTracker,BusyTracker,Stance,Options1,SharedCooldowns(),GetMagicSkill; the spellbook has noSpellobjects (SpellBook.Get,[id], components,GetSelfBuffs). - Missing events:
OnSharedCooldownsChanged,OnCastSpellAttempt,OnConfirmationRequest,OnRender2D/3D,OnWindowMessage, fellowship events,game.Messages. Nogame.Characters/MaxAllowedCharacters. - Other UB modules (
acclient,ubnet,http,acmessages,ace.datloader,ace.entity) aren't there; some of acclient's movement is inrynth.ai. - Script windows (the first version):
- Results come one pass late, and layout queries (
GetWindowSize,GetContentRegionAvail,GetWindowPos) give last frame's values. - Not yet: tables, tabs, popups and menus,
BeginCombo,InputTextMultiline, colour pickers, item-state queries (IsItemHovered,IsItemClicked, ...),PushStyleVar, fonts, image files (CreateTexture), draw lists, plots, and the script's ownImGui.Begin/End. The hud'sicon(CreateHud(name, icon)) isn't shown in the bar. - Icons:
GetObjectIconTexturedraws the underlay, icon and overlay, not AC's other item decorations (the magical glow ofIconEffects, stack numbers); the drawn pictures are kept at up to 256. - When the player closes a
CollapsingHeader, the items after it in the same region (up to the next header) are left out for about one tick, until the next pass arrives; when the player opens one, its contents appear with the next pass. SetNextWindowSizeConstraintsuses only the minimum;SetNextWindowPos' pivot andCalcTextSize's wrap width are ignored.WindowSettingshonours only the flags listed above (noAlwaysAutoResize,NoResizeorNoMoveyet).views.Availableis checked at most once a second.- Remembered open/closed choices apply when a hud is created, not when a running global script's character changes.
- Results come one pass late, and layout queries (
required files can'tsleeporawaitat their top level, and agame.Worldfilter function can't either.- Per-character things (
storage.Character, "character" autostart) need a logged-in character.
Coming from UtilityBelt#
A UB script's require lines change (RynthLua answers only its own module names: require("json"), require("filesystem"); no utilitybelt.* names). Past that, most UB code runs as it is:
game,game.Character,game.World,game.Actions,game.ActionQueue,game.ServerName,AccountName,CharacterId,State(compare withClientState.X),Capabilities.- Events with
Add/Once/Until/Remove(any case), one args table with UB's field names:OnVitalChanged {Type, Value, OldValue},OnLevelChanged {Level, OldLevel},OnVitaeChanged {Vitae, OldVitae},OnTotalExperienceChanged,OnAvailableLuminanceChanged,OnStateChanged {NewState},OnEnchantmentsChanged {Type, LayeredSpellId, Enchantment},OnObjectCreated/OnObjectReleased {ObjectId},OnChatText/OnTell/OnLocalMessage/OnChannelMessage/OnFellowMessage/OnEmote {SenderId, SenderName, Message, Room, Type, Eat},OnChatInput {Text, Eat},OnObjectSelected {ObjectId},OnContainerOpened/Closed {Container},OnDeath {Text, KillerId},OnPortalSpaceEntered/Exited,wo.OnPositionChanged {Weenie, Position},wo.OnDestroyed {ObjectId}, the Trade and Vendor events,game.OnTick,game.World.OnTick,game.OnScriptEnd. - Actions: the same names, argument order and defaults, options (
ActionOptions.new()or a table:Priority,TimeoutMilliseconds,MaxRetryCount,SkipChecks,Name), trailing callback,RunAllOrdered, vendor / trade / salvage / tell / wand / autorun / Blank,ActionType(a.ActionType == ActionType.Inventory),ActionErrornames, and on the actionSuccess,Error,ErrorDetails,IsFinished,IsStarted,IsRunning,CurrentRetryCount,Priority,Options,Await(),NewStackObjectId. - WorldObject:
wo:Value(IntId.X [, default])andHasValuefor every property kind, the action methods (incl.AddToSalvage,AddToTrade,Salvage),Id,Name,WeenieClassId,ObjectClass,ObjectType(:HasFlags),ContainerId,Container,WielderId,Wielder,Burden,HasAppraisalData,CurrentWieldedLocation,ValidWieldedLocations,Material, ..., the list properties (Items,ItemIds,Containers,AllItems,Equipment, ...),SpellIds,ServerPosition,DistanceTo2D/DistanceTo2d/DistanceTo3D,GetTopmostParent(); on your weenieVitals/Skills/Attributeskeyed by the enums (Current,Base,Max,Training,Type). - World:
game.World[id],Get,TryGet,Exists,GetAll,GetLandscape,GetNearest(filter, DistanceType)with ObjectClass, ObjectType, name or function filters,Selected,OpenContainer,Vendor. - Character:
Id,Weenie,Vitae,InPortalSpace,CombatMode,BurdenUnits,MaxBurdenUnits,Inventory/Containers/Equipment(lists),GetInventory,GetFirstInventory,GetInventoryCount,ActiveEnchantments(),AllEnchantments(),SpellBook.IsKnown/Count/KnownSpellsIds,Trade. - Enums: UB's names and numbers (VitalId 1/3/5,
SkillId.MissleWeapons, ...),ToNumber(),HasFlags/AddFlags/RemoveFlags;tostringof the typed ones gives the name. - json:
json.parse,json.serialize,json.null(),json.isnullas well as rxi-stylejson.encode/json.decode. - Lists:
ipairs(list),#listandfor x in list do.
Differs on purpose or by design:
- Module names: only RynthLua's (see above). A UB script's own bundled
json.luais shadowed by the built-injson(sameencode/decodenames). - Most enums are plain numbers (
tostring(SkillId.Axe)is "1"; get a name withSkillId[n]or the*Nametwin fields). Only the property ids other than IntId and ObjectType are typed values.ClientStateandActionErrorvalues are text. game.Stateis text ("InGame";== ClientState.In_Gameworks);game.LastTickand the actions'StartedAt/FinishedAtareclock()milliseconds, not dates; an enchantment'sExpiresAtis Unix seconds.- Event args are plain Lua tables; incoming chat can't be eaten, and
OnChatInputeating starts from a command's second line (see Known limits). OnObjectCreatedalso carriesObject;OnObjectSelectedalsoPreviousId,Object.ActionQueue.Adddoesn't add (actions queue when made);Removereturns true/false and only touches your own actions. Other scripts' actions show as summary tables.- Actions are checked for real completion (the server's UseDone and refusal codes, items moving, ...); which failures they report is RynthLua's (see the error table).
- filesystem:
GetScript()is read-only here (UB lets a script write to its own folder); noGetCustom,DeleteDirectory,CanWriteFile,IsValidFilePath,IsValidDirectoryPath,OnAccessChanged. Calls returnvalue, error, which is most likely the same shape UB'sref errorgives in Lua. - Huds (script windows): most UB huds port with a few changes.
- Change the views
requireline torequire("views"); RynthLua answers no UtilityBelt module names.require("imgui")stays as it is (.ImGuion it works too). - Unchanged:
views.Huds.CreateHud(name),Visible,ShowInBar,Title,WindowSettings(the honoured subset),OnRender/OnPreRender/OnShow/OnHidewith.Add, ImGui.NET's names and argument order,refvalues as extra returns (changed, v = ImGui.Checkbox(...),changed, n = ImGui.InputInt(...)), 0-basedCombo,Vector2.newand the enum names. - Icons as in UB:
local tex = views.Huds.GetIconTexture(id)once, thenImGui.Image(tex.TexturePtr, size)orImGui.ImageButton("id", tex.TexturePtr, size).CreateTexture(file)(image files) isn't there.OnCreateTextures/OnDestroyTexturesaren't needed: textures stay valid for the whole script, through device resets and hot reloads. - No
ImGui.Begin/Endof your own and noDontDrawDefaultWindow: the hud is the window. Put its size inOnPreRenderwithSetNextWindowSize, or inhud.DefaultSize. OnRendercan'tsleeporawait; start a thread withspawnfor that.- Results arrive one pass late (a click shows up on the hud's next pass, about a tick later). Code that works in UB keeps working; same-frame layout arithmetic gets last frame's values.
- Functions outside the supported set raise a clear error naming the function; see Known limits for what isn't there yet.
- The window has RynthCore's frame unless
hud.Chrome = "none"(orNoTitleBar).
- Change the views
- Missing actions and events: see Known limits. Scripts live in
C:\Games\RynthSuite\RynthLua\Scripts\, withscript.jsonas the manifest. - Extras UB doesn't have:
sleepanywhere (handlers too), the tick budget,game.RegisterCommand,storage/storage.Character,require("rynth.ai"), the*Namefields,Character.Health/MaxHealth-style shortcuts,IsBusy,Kindon actions,ObjectUseOn/ObjectApply,wo:Split, the v1 globals, and for hudsRefreshRate,Chrome,DefaultSize,LastError,views.Available,GetObjectIconTexture,GetSpellIconTexture, a number asImGui.Image's texture, andImage's default size (32 x 32).