client

Client session flags, world membership, and host preferences.

Methods
217
Fields
None

Getting one

client

Methods

MethodReturnsDescription
getGameState()GameStateThe game state (GameState.of of the client's value; UNKNOWN for one with no constant).
setGameState(GameState)()Set the game state through the client's own setter. LOADING while logged in reloads the scene: its GameStateChanged is posted at once,…
getTickCount()numberGame ticks since the client started, bumped right after the GameTick subscribers ran.
getGameCycle()numberThe client cycle counter (every 20 ms client cycle, in every game state).
getWorld()numberThe world the client is on (or will log in to, on the login screen).
getWorldType(){[WorldType]: boolean}The current world's types, as a set (WorldType.fromMask of its flags).
getRevision()numberThe game build's revision (242 on 242-1); 0 for a build this client has no profile of.
getFPS()numberFrames drawn over the last second.
getAccountHashString()stringThe logged-in account's hash as its decimal string ("-1" when not logged in). A 64-bit hash does not fit a Luau number exactly, so the hash…
getUsername()stringThe login screen's username field ("" before there is one).
setUsername(string)()Set the login screen's username field; a UsernameChanged follows. Game thread only.
setOtp(string)()Set the login screen's authenticator code field (login index 4), to paste a code into it; nothing is posted. The client's own submit takes…
getLoginIndex()numberWhich login screen page is up: 0 the welcome page, 2 the credentials, and so on (the client's login state).
getCurrentLoginField()numberThe credentials field with focus: 0 the username, 1 the password.
createWorld()WorldA new, empty world description to fill in with the World setters.
changeWorld(World)()On the login screen, switch the world the client will log in to (the client's own world change, through Bento's world hopper). Only the wor…
hopToWorld(World)()Logged in, hop to the world through the world switcher (a virtual-mouse click on its row; the switcher is opened first when it is not open)…
getLocalPlayer()Player?The local player, or nil before the client has one.
getNpcs(){NPC}The top-level world view's NPCs (also getTopLevelWorldView():npcs()).
getPlayers(){Player}The players the client's player info lists.
getTopLevelWorldView()WorldViewThe top-level world view (the scene the local player is in; boats have their own).
getWorldView(number)WorldView?World view id, or nil when the client has none with that id.
getScene()SceneThe top-level world view's scene.
getProjectiles(){Projectile}Every projectile in flight.
getCollisionMaps(){ n: number, [number]: CollisionData? }The top-level world view's collision maps, one per plane (nil with no scene).
getTileSettings(){{{number}}}The top-level scene's tile settings, [plane][x][y] (a copy).
getItemDefinition(number)ItemCompositionItem id's definition, loaded through the client's cache on demand; an id with none answers the client's default (named "null").
getNpcDefinition(number)NPCComposition?NPC type id's definition (without the varbit transform), loaded on demand; nil when the client has none to give.
getObjectDefinition(number)ObjectCompositionLoc type id's definition.
getVarbitValue(number)number(Client, number) -> number: Varbit varbit's value, read through its definition (loaded on demand). 0 for an id the client has no varbit…
getVarbitValue({number}, number)number
getServerVarbitValue(number)numberVarbit varbit as the server last sent it.
getVarpValue(number)numberVarp varp's value; raises for an id past the client's varps, and for one that is not an int.
getServerVarpValue(number)numberVarp varp as the server last sent it.
getVarps(){number}Every varp, a copy taken now: index varp + 1 is varp varp.
getServerVarps(){number}Every varp as the server last sent it, indexed as getVarps().
setVarpValue(number, number)()Set varp varp client-side (the server does not hear it): no VarbitChanged is posted, and a later change is reported from the value the…
setVarbit(number, number)()Set varbit varbit client-side (the server does not hear it): the value masked to the varbit's bits. No VarbitChanged is posted. Raises…
getVarbit(number)VarbitComposition?Varbit varbit's definition, or nil for an id the client has none for.
getIndexScripts()IndexDataBaseThe clientscripts index (cache archive 12): whether Bento's script overlays still apply (isOverlayOutdated()).
getIndexConfig()IndexDataBaseThe config index (cache archive 2), whose groups are the cache's definitions (group 14 the varbits, listed with getFileIds(14)).
getIndex(number)IndexDataBase?Cache index id (archive id: 2 the config, 7 the models, 8 the sprites, 12 the scripts), or nil for one Bento does not serve. Served a…
macroExpand(string)strings with the client's text macros expanded: each @name@ is replaced by the value the game's scripts set for that name, ignoring its case,…
getVarcIntValue(number)numberClient int var; 0 when it is unset.
getVarcStrValue(number)stringClient string var; "" when it is unset.
setVarcIntValue(number, number)()Set client int var (no VarClientIntChanged). Game thread only.
setVarcStrValue(number, string)()Set client string var (no VarClientStrChanged). Game thread only.
getVarcMap(){ [number]: number | string }Every client var that holds a number or a string, by id: a copy taken now.
getRealSkillLevel(Skill)numberskill's real (unboosted) level. Raises when the client's stats cannot be read ("the client's stats are not readable"); `getRealSkillLevel…
getBoostedSkillLevel(Skill)numberskill's current (boosted or drained) level. Raises when the client's stats cannot be read, as getRealSkillLevel does; `getBoostedSkillL…
getSkillExperience(Skill)numberskill's experience; -1 for a skill past the client's arrays.
getRealSkillLevels(){number}Every real level, by skill: index Skill.X:ordinal() + 1.
getBoostedSkillLevels(){number}Every current level, indexed as getRealSkillLevels().
getSkillExperiences(){number}Every skill's experience, indexed as getRealSkillLevels().
getTotalLevel()numberThe total level: the real levels of every skill Skill names.
getOverallExperience()numberThe total experience: every entry of the client's experience array.
getEnergy()numberRun energy in hundredths of a percent (0..=10000).
getWeight()numberCarried weight, in kilograms.
queueChangedSkill(Skill)()Mark skill changed, so the interfaces' stat listeners run again at the next interface tick, as after a stat update from the server (no `S…
queueChangedVarp(number)()Apply varp varp's engine settings again and mark it changed, so the interfaces' var listeners run again at the next interface tick (no `V…
isPrayerActive(Prayer)booleanWhether prayer is on (its varbit is 1).
isInInstancedRegion()booleanWhether the loaded map is an instance.
getInstanceTemplateChunks(){{{number}}}?The instance's template chunks, [plane][x][y] (each index + 1 in Luau), packed as InstanceTemplates has them; -1 for a chunk with none.…
getMapRegions(){number}The region ids the loaded map was built from.
getLocalDestinationLocation()LocalPoint?The tile the player is walking to (the destination flag), in the top-level world view; nil when there is none.
getBaseX()numberThe top-level scene's base x (0 when no scene is loaded).
getBaseY()numberThe top-level scene's base y (0 when no scene is loaded).
getPlane()numberThe top-level world view's plane.
getCameraX()numberThe camera's east coordinate, local units.
getCameraY()numberThe camera's north coordinate, local units (y is north).
getCameraZ()numberThe camera's height (z).
getCameraPitch()numberThis frame's camera pitch (0..2047 of a full turn's 16384 units).
getCameraYaw()numberThis frame's camera yaw (0..16383).
getCameraPitchTarget()numberThe pitch the camera is turning towards.
getCameraYawTarget()numberThe yaw the camera is turning towards.
setCameraPitchTarget(number)()Turn the camera towards pitch; the client eases to it. Game thread only.
setCameraYawTarget(number)()Turn the camera towards yaw; the client eases to it. Game thread only.
setCameraPitchRelaxerEnabled(boolean)()Lift (or restore) the camera's pitch limits. Game thread only.
getScale()numberThe 3D projection's focal length.
getOculusOrbState()numberThe free-camera ("oculus orb") state: 0 follows the player.
setOculusOrbState(number)()Set the free-camera state. Game thread only.
getOculusOrbFocalPointX()numberThe camera's focal point, east.
getOculusOrbFocalPointY()numberThe camera's focal point, north.
getCameraFocusPoint()LocalPoint?The point the camera orbits, a local point in the top-level world view: what getCameraFocus() answers on client:getCameraFocusEntity()'…
getCameraFocusWorldView()WorldView?The world view of the entity the camera follows (client:getCameraFocusEntity():getWorldView()), without the entity. A player or an NPC an…
getCameraFocusEntity()CameraFocusableEntity?What the camera follows: the Player or NPC (the handle every other read of it gives, so == against getLocalPlayer() holds), the `Wo…
setAllWidgetsAreOpTargetable(boolean)()Make every widget take a targeted op (a spell or an item's "Use" on it) while value is set: every widget's click mask carries `WidgetConf…
getMinimapZoom()numberHow far the minimap is zoomed (pixels per tile; 4 is the client's default, which it also answers before the client has a minimap).
setCameraSpeed(number)()Scale how fast the arrow keys and a mouse drag turn the camera: 1 is the client's speed, clamped to 0.2..5. Game thread only. Raises on a c…
setInvertPitch(boolean)()Make a mouse drag of the camera turn its pitch the other way (the arrow keys are not inverted). Game thread only; raises as `setCameraSpeed…
setInvertYaw(boolean)()Make a mouse drag of the camera turn its yaw the other way (the arrow keys are not inverted). Game thread only; raises as setCameraSpeed…
setCameraShakeDisabled(boolean)()Stop (or let again) the camera shaking when the game shakes it: the camera's five shake axes are skipped. The pitch floor a shake sets is k…
setOculusOrbNormalSpeed(number)()The free camera's ("oculus orb") speed without Shift held: the client's own setting (12 by default; the game's scripts set it too). Game th…
setMinimapZoom(number)()(Client, number) -> (): Zoom the minimap to zoom pixels per tile, clamped to 2..8, through the client's own zoom (which redraws the min…
setMinimapZoom(boolean)()
isMinimapZoom()booleanWhether the minimap zoom is on: the flag setMinimapZoom(enabled) sets, read from the client's minimap, so it also follows the game's own…
setCameraMouseButtonMask(number)()Which mouse buttons drag the camera while held: bit b set for button b (1 left, 2 right, 4 middle; 20 is right and middle). 0 puts back…
drawInstanceMap(number)SpritePixelsA picture of plane z (0..3) of the loaded scene, 736 pixels a side (the 184-tile extended scene at 4 pixels a tile, north up), drawn by t…
getCanvasWidth()numberThe canvas width, pixels: the canvas the game lays its interfaces out in and draws, the window over the client's own UI scale (its "UiScali…
getCanvasHeight()numberThe canvas height, pixels (see getCanvasWidth).
getRealDimensions()DimensionThe canvas size: the window over the client's own UI scale (its "UiScaling" setting), raised to keep 765 × 503 at the window's aspect. Whil…
getStretchedDimensions()DimensionThe size the canvas is drawn at, in the units a plugin sees: the canvas size, as getRealDimensions(). The client stretches its canvas to…
isStretchedEnabled()booleanWhether stretched mode is on: what setStretchedEnabled last set, client-wide (false until then). The client draws its canvas at its own…
setStretchedEnabled(boolean)()Turn stretched mode on or off, client-wide. The canvas changes at the next invalidateStretching(true).
setScalingFactor(number)()How much smaller than the window resizable mode draws the game before stretching it, percent (the scale is 1 + factor / 100: 50 draws at…
invalidateStretching(boolean)()Apply stretched mode. With resize: while stretched mode is on in resizable mode, the client's own "UiScaling" setting becomes `100 + fact…
getViewportXOffset()numberWhere the 3D viewport starts on the canvas, x.
getViewportYOffset()numberWhere the 3D viewport starts on the canvas, y.
getViewportWidth()numberThe 3D viewport's width.
getViewportHeight()numberThe 3D viewport's height.
isResized()booleanWhether the client is in resizable mode.
getMouseCanvasPosition()PointThe cursor, canvas pixels.
getMouseIdleTicks()numberClient cycles since the last mouse event (a move, press or wheel notch).
getKeyboardIdleTicks()numberClient cycles since the last key went down or up.
getMouseCurrentButton()numberThe mouse buttons held: 1 left, 2 right, 4 middle; 0 for none.
getMouseLastPressedMillis()numberWhen a mouse button last went down, Unix epoch milliseconds; 0 before the first press. The time since is `Instant.now():toEpochMilli() - cl…
getDragTime()numberClient cycles the clicked widget has been held (the drag's age).
isKeyPressed(number)booleanWhether key keycode (KeyCode, the client's own key codes) is held.
getIdleTimeout()numberHow long the client waits idle before logging out, client cycles (the client's "AFK timeout" setting, which it keeps in whole minutes: 1500…
setIdleTimeoutMinutes(number)()Set the idle logout, in whole minutes: the client keeps it in minutes (its "AFK timeout" setting). For a timeout in ticks, `setIdleTimeoutM…
hasHintArrow()booleanWhether the server hint arrow is showing.
getHintArrowType()numberThe hint arrow's type (HintArrowType).
getHintArrowPoint()WorldPoint?The tile a coordinate hint arrow points at; nil for any other type.
setHintArrow(WorldPoint)()(Client, WorldPoint) -> (): Point the hint arrow at the middle of point. Game thread only.
setHintArrow(LocalPoint)()
setHintArrow(NPC)()
setHintArrow(Player)()
clearHintArrow()()Hide the hint arrow. Game thread only.
getHintArrowNpc()NPC?The NPC an NPC hint arrow points at; nil for any other arrow, or one whose NPC is gone.
getHintArrowPlayer()Player?The player a player hint arrow points at; nil otherwise.
getGrandExchangeOffers(){GrandExchangeOffer}The eight Grand Exchange slots' offers, in slot order (an empty slot is an EMPTY offer). Empty when the client has none yet.
setGeSearchResultIds({number}?)()The ids the Grand Exchange search shows, in order, for a GrandExchangeSearched subscriber that consumed the event (nil: none). Each is…
setGeSearchResultCount(number)()How many of those ids the search shows; -1 is the client's "too many matches". Kept, never refused, as setGeSearchResultIds is.
setGeSearchResultIndex(number)()The next id the search reads (0 starts over). Kept, never refused, as setGeSearchResultIds is.
getItemCount()numberHow many item definitions the client's cache holds: item ids run from 0 to one below it, so a search walks them (`itemManager:getItemCompos…
playSoundEffect(number)()(Client, number) -> (): Play sound effect id as the client's own synth packet does. Game thread only.
playSoundEffect(number, number, number, number)()
playSoundEffect(number, number, number, number, number)()
playSoundEffect(number, number)()
getAmbientSoundEffects()AmbientSoundEffectDequeThe top-level world view's ambient sounds: the looping area sounds its locs and NPCs make. `for _, effect in client:getAmbientSoundEffects(…
getPreferences()PreferencesThe client's preferences: the remembered username and the sound effect volume.
changeMemoryMode(boolean)()Turn the client's low detail on (or off): the client's own low-detail flag (the one its lowmem / highmem commands set), then, while log…
setUnlockedFps(boolean)()Let the client draw frames apart from its 20 ms cycle: paced to setUnlockedFpsTarget's rate, or not at all until one is set (cleared by `…
setUnlockedFpsTarget(number)()The frame rate to pace to while the FPS is unlocked (setUnlockedFps(true)); 0 or less is none. Kept while locked, and applied when unlock…
setExpandedMapLoading(number)()Draw the map chunks zones (8 tiles each) past the 104 tiles the game loads, on every side: 117HD's "Expanded map loading". 0 (the default…
getExpandedMapLoading()numberThe chunks setExpandedMapLoading last set (0 until one is set).
getTextureProvider()TextureProviderThe client's textures: their brightness, the textures themselves and their pixels (TextureProvider).
setShouldRenderLoginScreenFire(boolean)()Whether the title screen's fire is drawn (true by default). While false the client's fire is neither drawn nor animated, wherever the clien…
setAnimationInterpolationFilter(((number) -> boolean)?)()Which animations the client tweens between frames (animation smoothing): players, NPCs, animated objects and the spot animations on actors…
getAnimationInterpolationFilter()((number) -> boolean)?The animation smoothing filter last set (setAnimationInterpolationFilter), by any plugin, or nil while smoothing is off.
drawOriginalMenu(number)()Draw the client's own menu now, at alpha (0 transparent .. 255 opaque): call it from a BeforeMenuRender subscriber, then `event:consume…
getFollower()NPC?The local player's follower (a pet, a familiar, a quest follower), or nil: the first follower varp the session changed (`VarPlayerID.FOLLOW…
getScriptActiveWidget()Widget?The widget the running script's cc_* instructions act on (the script VM's active component register: the component cc_find found or `cc…
getFocusedInputFieldWidget()Widget?The widget whose input field has the keyboard focus (a field the game types into instead of the chatbox), or nil when none has it.
getArray(number){number}?The running script's int array in local arrayId (the script's own array): arr[i] reads value i - 1, arr[i] = v writes it on the gam…
closeInterface(WidgetNode, boolean)()Close the sub-interface interfaceNode names client-side, as the client closes one (no packet; the group unloaded when unload; `WidgetCl…
openWorldHopper()()Open the world switcher, through the virtual mouse: the logout panel first when another is showing, then its "World Switcher" button. It op…
getWidget(number)Widget?(Client, number) -> Widget?: The widget with packed id id (group << 16 | child), or nil when its interface is not loaded. Raises when…
getWidget(number, number)Widget?
getWidgetRoots(){Widget}The top-level interface's root components.
getComponentTable(){[number]: WidgetNode}Every open sub-interface, keyed by the component it is open in: client:getComponentTable()[componentId].
getWidgetConfig(Widget)WidgetConfigNode?The IF_SETEVENTS masks the server set on the widget's component and slot; nil when it set none (the widget's own getClickMask() applies…
getTopLevelInterfaceId()numberThe top-level interface's id, -1 when none is open.
getDraggedWidget()Widget?The draggable widget a mouse press landed on (the client's clicked widget), from the press until the release, whether or not the drag has b…
getDraggedOnWidget()Widget?The widget under the dragged one that takes a drop (its config has WidgetConfig.DRAG_ON), as the client found it this cycle; nil when the…
setDraggedOnWidget(Widget?)()Where the drag in progress drops (nil: nowhere, so the release sends no IF_BUTTOND). The client derives it again every cycle: set it from…
isWidgetSelected()booleanWhether a widget is in target mode: a spell or an item's "Use" is selected.
getSelectedWidget()Widget?The widget in target mode (the selected spell, or the inventory slot of a "Use" item); nil when none is, or it is gone.
setWidgetSelected(boolean)()false turns target mode off: nothing else runs (no onTargetLeave; a plugin that changed the source widget's look restores it). true k…
getItemContainer(number)ItemContainer?(Client, number) -> ItemContainer?: Item container id (an InventoryID), or nil when the client has none.
getItemContainer(LegacyInventoryID)ItemContainer?
runScript(...any)()Run clientscript args[1] with the rest as its arguments, now, on the game thread: client:runScript(id, a, b) (or the arguments as one a…
createScriptEventBuilder(...any)ScriptEventBuilderA script event to fill in and run(): the script id first, then its arguments, as runScript takes them.
getIntStack(){number}The script VM's int stack, the interpreter's own array. While a ScriptCallbackEvent is delivered it is that event's stacks, and a write i…
getIntStackSize()numberThe int stack's size, where getIntStack() reads it.
setIntStackSize(number)()Set the int stack's size (staged into the ScriptCallbackEvent being delivered; an error anywhere else).
getObjectStack(){ number | string }The script VM's object stack (the strings scripts pass), as getIntStack() is the int stack: the event's while one is delivered, else the…
getObjectStackSize()numberThe object stack's size, where getObjectStack() reads it.
setObjectStackSize(number)()Set the object stack's size (staged into the ScriptCallbackEvent being delivered; an error anywhere else).
getMenu()MenuThe root right-click menu (one object for the client's life).
getMenuEntries(){MenuEntry}The menu's entries, in the client's order (getMenu():getMenuEntries()).
setMenuEntries({MenuEntry})()Replace the menu's entries (getMenu():setMenuEntries(entries)).
createMenuEntry(number)MenuEntryAdd an entry at idx (getMenu():createMenuEntry(idx); -1 is the top).
isMenuOpen()booleanWhether the right-click menu is open.
getMenuX()numberThe open menu's left edge, canvas pixels.
getMenuY()numberThe open menu's top edge.
getMenuWidth()numberThe open menu's width.
getMenuHeight()numberThe open menu's height.
addChatMessage(ChatMessageType, string, string, string?)MessageNode(Client, ChatMessageType, string, string, string?) -> MessageNode: Add a line to the chatbox through the client's own message add (a `Cha…
addChatMessage(ChatMessageType, string, string, string?, boolean)MessageNode
refreshChat()()Have the chatbox rebuild its lines (after a message node was changed).
getMessages()ChatMessageTableEvery chat message the chatbox holds, by message id.
getChatLineMap(){[number]: ChatLineBuffer}The chatbox's line buffers, by chat type.
getFriendContainer()FriendContainerThe friends list.
getIgnoreContainer()NameableContainerThe ignore list.
getFriendsChatManager()FriendsChatManager?The friends chat the player is in, or nil.
getClanChannel()ClanChannel?(Client) -> ClanChannel?: The player's clan channel, or nil.
getClanChannel(number)ClanChannel?
getGuestClanChannel()ClanChannel?The guest clan channel the player is in, or nil.
getClanSettings()ClanSettings?(Client) -> ClanSettings?: The player's clan's settings (its members, online or not), or nil.
getClanSettings(number)ClanSettings?
getGuestClanSettings()ClanSettings?The settings of the guest clan the player is in, or nil.
isFriended(string, boolean)booleanWhether name is on the friends list (and online, when mustBeLoggedIn).
getSpriteOverrides(){[number]: SpritePixels}The sprite overrides, sprite id to SpritePixels as a keyed table (the same table every call, shared by every plugin): `t[spriteId] = spri…
getWidgetSpriteOverrides(){[number]: SpritePixels}The widget sprite overrides, by packed widget id (InterfaceID), the same keyed table form: the widget draws sprite in place of its own…
getWidgetSpriteCache()NodeCacheThe client's widget sprite cache; reset() empties it (call it beside every override put and remove).
getModIcons(){IndexedSprite}?The chat icons <img=n> draws, as a live 1-based view of the client's array (one for every plugin): icons[n + 1] is the icon <img=n> d…
setModIcons({IndexedSprite})()Make modIcons (a table of IndexedSprites) the chat icons <img=n> draws, for every plugin. Each icon is copied into the client as it i…
createIndexedSprite()IndexedSpriteA new, empty IndexedSprite (no pixels, no palette, every size 0).
getMapDots(){SpritePixels}The minimap's dot sprites, a live 1-based view by dot id + 1 (DOT_ITEM 0 is dots[1], then DOT_NPC, DOT_PLAYER, DOT_FRIEND, `DOT_T…
setCompass(SpritePixels)()Make the minimap draw compass as its compass (copied as it is now) until the next call. An error on a client whose table does not place i…
getCrossSprites(){SpritePixels}?The click cross frames (4 yellow, then 4 red), as a live 1-based view of the array the client draws from (one for every plugin): `crosses[i…
resetHealthBarCaches()()Empty the client's health bar definition and sprite caches: every health bar, those already over an actor too, looks its sprites up again a…
setLoginScreen(SpritePixels?)()Draw pixels as the login screen's background (copied as it is now): wider than 765 centred, else at the login area's left, and 383 wide o…
getIndexSprites()IndexDataBaseThe sprites cache index (archive 8), for getSprites.
getSprites(IndexDataBase, number, number){SpritePixels}?Every frame of sprite group archiveId (a SpriteID), decoded now: the client's SpriteBuffer read, as spriteManager:getSprite reads o…
createSpritePixels({number}, number, number)SpritePixelsA sprite of pixels (width * height ints, row by row, as given: getPixels() answers them back unchanged, alpha included, and 0 draws n…
createItemSprite(number, number, number, number, number, boolean, number)SpritePixels?Item itemId's inventory sprite as the client draws it (quantity, border, shadowColor, stackable mode, scale), at once on the ga…
getWorldMap()WorldMapThe world map's view (whether or not it is open).
getEnum(number)EnumCompositionCache enum id, loaded on demand.
getDBTableField(number, number, number){ number | string }DB row rowID's values in column at tuple position tupleIndex (0-based): one per tuple the row holds there, or its table's default whe…
getDBRowsByValue(number, number, number, any){number}The rows of DB table table whose column holds value at tuple position tupleIndex (0-based), in the client's index order; empty when…
getDBTableRows(number){number}?Every row of DB table table, in the client's index order (its master index), or nil when the client has none for it. On the game thread…
getMapElementConfig(number)MapElementConfigMap element definition id (the client loads them all once, at the cache load). Raises for an id past the definitions, before the load, an…
getStructComposition(number)StructCompositionCache struct id.
createClientObject()ClientObjectA new client-side scene entity of this plugin, inactive, a ClientObject Drawn by the client's own scene in SD, and by its HD renderer in…
loadModel(number, {number}?, {number}?)Model?(Client, number) -> Model?: Cache model id, lit with ModelData's defaults; nil when the cache has no such model (the SD model in ei…
loadModelData(number)ModelData?Cache model id's data, to recolour and light; nil when the cache has no such model. Each call makes a new one, so a recolour never reac…
loadAnimation(number)Animation?Sequence id, for ClientObject:setAnimation; nil for one with no frames that is not skeletal.
getBufferProvider()BufferProvider?The client's frame buffer: the canvas-sized ARGB image the client draws its whole interface into (the 3D scene is drawn on the GPU and comp…

Method details

setGameState

setGameState: (Client, GameState) -> ()

Set the game state through the client's own setter. LOADING while logged in reloads the scene: its GameStateChanged is posted at once, and the LOGGED_IN one when the reload ends. Any other change is posted at the start of the next client cycle. UNKNOWN and LOGIN_SCREEN_AUTHENTICATOR raise: the client has no such state. Game thread only.

getTickCount

getTickCount: (Client) -> number

Game ticks since the client started, bumped right after the GameTick subscribers ran.

getGameCycle

getGameCycle: (Client) -> number

The client cycle counter (every 20 ms client cycle, in every game state).

getWorld

getWorld: (Client) -> number

The world the client is on (or will log in to, on the login screen).

getRevision

getRevision: (Client) -> number

The game build's revision (242 on 242-1); 0 for a build this client has no profile of.

getFPS

getFPS: (Client) -> number

Frames drawn over the last second.

getAccountHashString

getAccountHashString: (Client) -> string

The logged-in account's hash as its decimal string ("-1" when not logged in). A 64-bit hash does not fit a Luau number exactly, so the hash comes as a string. Use it as a key.

getUsername

getUsername: (Client) -> string

The login screen's username field ("" before there is one).

setUsername

setUsername: (Client, string) -> ()

Set the login screen's username field; a UsernameChanged follows. Game thread only.

setOtp

setOtp: (Client, string) -> ()

Set the login screen's authenticator code field (login index 4), to paste a code into it; nothing is posted. The client's own submit takes the field only when it is six characters long. Game thread only; raises on a client whose table does not place the field.

getLoginIndex

getLoginIndex: (Client) -> number

Which login screen page is up: 0 the welcome page, 2 the credentials, and so on (the client's login state).

changeWorld

changeWorld: (Client, World) -> ()

On the login screen, switch the world the client will log in to (the client's own world change, through Bento's world hopper). Only the world's id is used; the rest is looked up in the world list.

hopToWorld

hopToWorld: (Client, World) -> ()

Logged in, hop to the world through the world switcher (a virtual-mouse click on its row; the switcher is opened first when it is not open). Only the world's id is used.

getNpcs

getNpcs: (Client) -> {NPC}

The top-level world view's NPCs (also getTopLevelWorldView():npcs()).

getTileSettings

getTileSettings: (Client) -> {{{number}}}

The top-level scene's tile settings, [plane][x][y] (a copy).

getItemDefinition

getItemDefinition: (Client, number) -> ItemComposition

Item id's definition, loaded through the client's cache on demand; an id with none answers the client's default (named "null").

getNpcDefinition

getNpcDefinition: (Client, number) -> NPCComposition?

NPC type id's definition (without the varbit transform), loaded on demand; nil when the client has none to give.

getVarbitValue

getVarbitValue: ((Client, number) -> number) & ((Client, {number}, number) -> number)

(Client, number) -> number: Varbit varbit's value, read through its definition (loaded on demand). 0 for an id the client has no varbit for.

(Client, {number}, number) -> number: Varbit varbit out of a varp array the caller holds (varps[1] is varp 0, as getVarps() hands it out). 0 when its varp is past the array.

getVarpValue

getVarpValue: (Client, number) -> number

Varp varp's value; raises for an id past the client's varps, and for one that is not an int.

getVarps

getVarps: (Client) -> {number}

Every varp, a copy taken now: index varp + 1 is varp varp.

getServerVarps

getServerVarps: (Client) -> {number}

Every varp as the server last sent it, indexed as getVarps().

setVarpValue

setVarpValue: (Client, number, number) -> ()

Set varp varp client-side (the server does not hear it): no VarbitChanged is posted, and a later change is reported from the value the server last set. Game thread only.

setVarbit

setVarbit: (Client, number, number) -> ()

Set varbit varbit client-side (the server does not hear it): the value masked to the varbit's bits. No VarbitChanged is posted. Raises for an id the client has no varbit for. Game thread only.

getIndexConfig

getIndexConfig: (Client) -> IndexDataBase

The config index (cache archive 2), whose groups are the cache's definitions (group 14 the varbits, listed with getFileIds(14)).

getIndex

getIndex: (Client, number) -> IndexDataBase?

Cache index id (archive id: 2 the config, 7 the models, 8 the sprites, 12 the scripts), or nil for one Bento does not serve. Served are 0 to 15 and 17 to 22. Not served: 16, which the client keeps no archive for; 23, 24 and 25, which the client can leave pointing at archives it has freed while it reloads its cache, so they cannot be read safely; and any other number.

macroExpand

macroExpand: (Client, string) -> string

s with the client's text macros expanded: each @name@ is replaced by the value the game's scripts set for that name, ignoring its case, and by nothing when they set none (@blu@text is <col=0000ff>text). The rest of s is kept, tags and all. Widget text and chat messages may hold macros, so run them through this before matching what the game shows. Raises on a client whose offset table does not place the macro table.

setVarcIntValue

setVarcIntValue: (Client, number, number) -> ()

Set client int var (no VarClientIntChanged). Game thread only.

setVarcStrValue

setVarcStrValue: (Client, number, string) -> ()

Set client string var (no VarClientStrChanged). Game thread only.

getVarcMap

getVarcMap: (Client) -> { [number]: number | string }

Every client var that holds a number or a string, by id: a copy taken now.

getRealSkillLevel

getRealSkillLevel: (Client, Skill) -> number

skill's real (unboosted) level. Raises when the client's stats cannot be read ("the client's stats are not readable"); getRealSkillLevels() is the form with no raise, empty then.

getBoostedSkillLevel

getBoostedSkillLevel: (Client, Skill) -> number

skill's current (boosted or drained) level. Raises when the client's stats cannot be read, as getRealSkillLevel does; getBoostedSkillLevels() is the form with no raise, empty then.

getTotalLevel

getTotalLevel: (Client) -> number

The total level: the real levels of every skill Skill names.

getEnergy

getEnergy: (Client) -> number

Run energy in hundredths of a percent (0..=10000).

queueChangedSkill

queueChangedSkill: (Client, Skill) -> ()

Mark skill changed, so the interfaces' stat listeners run again at the next interface tick, as after a stat update from the server (no StatChanged is posted). Logged in, on the game thread only: the client's changed-stat counter is also its logged-in gate, so outside a session this raises.

queueChangedVarp

queueChangedVarp: (Client, number) -> ()

Apply varp varp's engine settings again and mark it changed, so the interfaces' var listeners run again at the next interface tick (no VarbitChanged is posted). Logged in, on the game thread only.

getInstanceTemplateChunks

getInstanceTemplateChunks: (Client) -> {{{number}}}?

The instance's template chunks, [plane][x][y] (each index + 1 in Luau), packed as InstanceTemplates has them; -1 for a chunk with none. Nil when the client has no map.

getBaseX

getBaseX: (Client) -> number

The top-level scene's base x (0 when no scene is loaded).

getBaseY

getBaseY: (Client) -> number

The top-level scene's base y (0 when no scene is loaded).

getCameraX

getCameraX: (Client) -> number

The camera's east coordinate, local units.

getCameraY

getCameraY: (Client) -> number

The camera's north coordinate, local units (y is north).

getCameraPitch

getCameraPitch: (Client) -> number

This frame's camera pitch (0..2047 of a full turn's 16384 units).

setCameraPitchTarget

setCameraPitchTarget: (Client, number) -> ()

Turn the camera towards pitch; the client eases to it. Game thread only.

setCameraYawTarget

setCameraYawTarget: (Client, number) -> ()

Turn the camera towards yaw; the client eases to it. Game thread only.

getCameraFocusPoint

getCameraFocusPoint: (Client) -> LocalPoint?

The point the camera orbits, a local point in the top-level world view: what getCameraFocus() answers on client:getCameraFocusEntity()'s result, without the entity. Nil when the client has no camera yet.

getCameraFocusWorldView

getCameraFocusWorldView: (Client) -> WorldView?

The world view of the entity the camera follows (client:getCameraFocusEntity():getWorldView()), without the entity. A player or an NPC answers the view it is in (a boat's while it is aboard one), a boat the view it carries, a fixed tile the top level. Nil before the client has a world view, or while the target is not in any. Raises on a client whose table does not place the target, rather than answer nil.

getCameraFocusEntity

getCameraFocusEntity: (Client) -> CameraFocusableEntity?

What the camera follows: the Player or NPC (the handle every other read of it gives, so == against getLocalPlayer() holds), the WorldEntity (a boat), or, while the camera is fixed on a tile, the client's coordinate entity (a CameraFocusableEntity). Each answers getCameraFocus() and getWorldView(). Nil before the client has a world view, or while the target is not in any. Raises on a client whose table does not place the target, rather than answer nil.

setAllWidgetsAreOpTargetable

setAllWidgetsAreOpTargetable: (Client, boolean) -> ()

Make every widget take a targeted op (a spell or an item's "Use" on it) while value is set: every widget's click mask carries WidgetConfig.WIDGET_USE_TARGET (set it while you pick a widget, as a widget inspector does). Game thread only; raises on a client whose table does not place the click mask.

getMinimapZoom

getMinimapZoom: (Client) -> number

How far the minimap is zoomed (pixels per tile; 4 is the client's default, which it also answers before the client has a minimap).

setCameraSpeed

setCameraSpeed: (Client, number) -> ()

Scale how fast the arrow keys and a mouse drag turn the camera: 1 is the client's speed, clamped to 0.2..5. Game thread only. Raises on a client whose table has the camera input off.

setInvertPitch

setInvertPitch: (Client, boolean) -> ()

Make a mouse drag of the camera turn its pitch the other way (the arrow keys are not inverted). Game thread only; raises as setCameraSpeed does.

setInvertYaw

setInvertYaw: (Client, boolean) -> ()

Make a mouse drag of the camera turn its yaw the other way (the arrow keys are not inverted). Game thread only; raises as setCameraSpeed does.

setCameraShakeDisabled

setCameraShakeDisabled: (Client, boolean) -> ()

Stop (or let again) the camera shaking when the game shakes it: the camera's five shake axes are skipped. The pitch floor a shake sets is kept. Game thread only; raises as setCameraSpeed does.

setOculusOrbNormalSpeed

setOculusOrbNormalSpeed: (Client, number) -> ()

The free camera's ("oculus orb") speed without Shift held: the client's own setting (12 by default; the game's scripts set it too). Game thread only; raises as setCameraSpeed does.

setMinimapZoom

setMinimapZoom: ((Client, number) -> ()) & ((Client, boolean) -> ())

(Client, number) -> (): Zoom the minimap to zoom pixels per tile, clamped to 2..8, through the client's own zoom (which redraws the minimap), while the minimap zoom is on; while it is off (setMinimapZoom(false)) this does nothing. The zoom is the client's own, on from the start. The client's zoom is whole pixels per tile, so a fraction is rounded to the nearest. Nothing changes before the client has a minimap and a scene. Game thread only; raises as setCameraSpeed does.

(Client, boolean) -> (): Turn the minimap zoom on (or off) and put the minimap back at the default zoom (4) either way. While it is off the player's mouse wheel does not zoom the minimap and setMinimapZoom(zoom) does nothing. The flag is the client's own minimap zoom flag, which the game's own minimap zoom setting also sets. Before the client has a scene the zoom reset is skipped (the client starts at 4). Called while a frame is drawn (from an overlay's render), the flag is set at once and the zoom goes back to 4 at the next client cycle, so getMinimapZoom() reads the old zoom until then. Game thread only; raises as setCameraSpeed does.

isMinimapZoom

isMinimapZoom: (Client) -> boolean

Whether the minimap zoom is on: the flag setMinimapZoom(enabled) sets, read from the client's minimap, so it also follows the game's own minimap zoom setting. The client starts it on, and before the client has made its minimap this answers true, the value the minimap's constructor stores. Raises on a client whose table has the camera input off, as setMinimapZoom does.

setCameraMouseButtonMask

setCameraMouseButtonMask: (Client, number) -> ()

Which mouse buttons drag the camera while held: bit b set for button b (1 left, 2 right, 4 middle; 20 is right and middle). 0 puts back the game's own rule (the middle button, by its option). A button keeps its own meaning: a right press still opens the menu. A mask without the middle bit does not stop the middle button dragging while the game's option is on (the client would take that press as a left click). Game thread only; raises on a client whose table does not place the press handling.

drawInstanceMap

drawInstanceMap: (Client, number) -> SpritePixels

A picture of plane z (0..3) of the loaded scene, 736 pixels a side (the 184-tile extended scene at 4 pixels a tile, north up), drawn by the client's own minimap code: floors, walls, doors and map icons, background 1. The 104-tile scene is at tile 40; the border round it is background (160 pixels off each side to crop it). The scene's outermost tile on each side is also background (the client builds no floor there). The minimap the player sees is not changed. Background only when nothing is loaded or z is not a plane. Game thread only; raises on a client whose table does not place the minimap draw.

getCanvasWidth

getCanvasWidth: (Client) -> number

The canvas width, pixels: the canvas the game lays its interfaces out in and draws, the window over the client's own UI scale (its "UiScaling" setting, whose default follows the monitor's DPI). The same unit as overlays, mouse events and getMouseCanvasPosition().

getRealDimensions

getRealDimensions: (Client) -> Dimension

The canvas size: the window over the client's own UI scale (its "UiScaling" setting), raised to keep 765 × 503 at the window's aspect. While stretched that is the window over 1 + factor / 100, by the same rule.

getStretchedDimensions

getStretchedDimensions: (Client) -> Dimension

The size the canvas is drawn at, in the units a plugin sees: the canvas size, as getRealDimensions(). The client stretches its canvas to the window by its own UI scale and maps the pointer back to the canvas itself, so mouse events, overlays and clicks are all in canvas pixels, and the stretched / real ratio is 1. This is not the window's own size in pixels.

isStretchedEnabled

isStretchedEnabled: (Client) -> boolean

Whether stretched mode is on: what setStretchedEnabled last set, client-wide (false until then). The client draws its canvas at its own UI scale either way.

setStretchedEnabled

setStretchedEnabled: (Client, boolean) -> ()

Turn stretched mode on or off, client-wide. The canvas changes at the next invalidateStretching(true).

setScalingFactor

setScalingFactor: (Client, number) -> ()

How much smaller than the window resizable mode draws the game before stretching it, percent (the scale is 1 + factor / 100: 50 draws at 1.5×), client-wide; applied by invalidateStretching(true) while stretched mode is on. The client's UI scale is 25..400 percent, so a factor outside -75..300 takes effect at the nearer end.

invalidateStretching

invalidateStretching: (Client, boolean) -> ()

Apply stretched mode. With resize: while stretched mode is on in resizable mode, the client's own "UiScaling" setting becomes 100 + factor percent through the client's setter, which recomputes the canvas and lays the interfaces out again as when the player changes the setting; otherwise the player's own value goes back (unless they changed it meanwhile). Without resize nothing changes. The player's own value is also kept outside the client while the setting holds a stretched one, so after an exit or a crash while stretched, turning stretched mode off still puts it back, and a session no plugin stretches starts at the player's own scale. The setting is the client's own, which the client saves, so until Bento next runs the client starts at the stretched scale; in fixed mode the game is drawn at the player's own scale. Game thread only; raises on a client whose table does not place the setting.

isResized

isResized: (Client) -> boolean

Whether the client is in resizable mode.

getMouseIdleTicks

getMouseIdleTicks: (Client) -> number

Client cycles since the last mouse event (a move, press or wheel notch).

getMouseLastPressedMillis

getMouseLastPressedMillis: (Client) -> number

When a mouse button last went down, Unix epoch milliseconds; 0 before the first press. The time since is Instant.now():toEpochMilli() - client:getMouseLastPressedMillis() (the wall clock; os is not in the sandbox, and utils:elapsedMs() counts from the client's start, so a difference with it is meaningless).

getDragTime

getDragTime: (Client) -> number

Client cycles the clicked widget has been held (the drag's age).

isKeyPressed

isKeyPressed: (Client, number) -> boolean

Whether key keycode (KeyCode, the client's own key codes) is held.

getIdleTimeout

getIdleTimeout: (Client) -> number

How long the client waits idle before logging out, client cycles (the client's "AFK timeout" setting, which it keeps in whole minutes: 15000 is five).

setIdleTimeoutMinutes

setIdleTimeoutMinutes: (Client, number) -> ()

Set the idle logout, in whole minutes: the client keeps it in minutes (its "AFK timeout" setting). For a timeout in ticks, setIdleTimeoutMinutes(math.ceil(ticks / 3000)). Not saved to the client's preferences file. Game thread only.

setHintArrow

setHintArrow: ((Client, WorldPoint) -> ()) & ((Client, LocalPoint) -> ()) & ((Client, NPC) -> ()) & ((Client, Player) -> ())

(Client, WorldPoint) -> (): Point the hint arrow at the middle of point. Game thread only.

(Client, LocalPoint) -> (): Point the hint arrow at point, within its tile. Game thread only.

(Client, NPC) -> (): Point the hint arrow at npc. Game thread only.

(Client, Player) -> (): Point the hint arrow at player. Game thread only.

getHintArrowNpc

getHintArrowNpc: (Client) -> NPC?

The NPC an NPC hint arrow points at; nil for any other arrow, or one whose NPC is gone.

setGeSearchResultIds

setGeSearchResultIds: (Client, {number}?) -> ()

The ids the Grand Exchange search shows, in order, for a GrandExchangeSearched subscriber that consumed the event (nil: none). Each is kept as a signed 16-bit value (an id over 32767 wraps, and comes back whole). Takes effect at the search's next result read. Never raises: on a client the search is not hooked on it is kept but nothing reads it, and the log says so once.

setGeSearchResultCount

setGeSearchResultCount: (Client, number) -> ()

How many of those ids the search shows; -1 is the client's "too many matches". Kept, never refused, as setGeSearchResultIds is.

setGeSearchResultIndex

setGeSearchResultIndex: (Client, number) -> ()

The next id the search reads (0 starts over). Kept, never refused, as setGeSearchResultIds is.

getItemCount

getItemCount: (Client) -> number

How many item definitions the client's cache holds: item ids run from 0 to one below it, so a search walks them (itemManager:getItemComposition(id) for each). 0 before the cache is loaded. Raises on a client whose table does not place the count.

playSoundEffect

playSoundEffect: ((Client, number) -> ()) & ((Client, number, number, number, number) -> ()) & ((Client, number, number, number, number, number) -> ()) & ((Client, number, number) -> ())

(Client, number) -> (): Play sound effect id as the client's own synth packet does. Game thread only.

(Client, number, number, number, number) -> (): Play sound effect id at scene tile (x, y), heard within range tiles. Game thread only.

(Client, number, number, number, number, number) -> (): playSoundEffect(id, x, y, range) after delay client cycles.

(Client, number, number) -> (): Play sound effect id now, at the player's sound effect volume, or at volume (0..127, SoundEffectVolume's scale) while the player has sound effects muted: past the client's queue, so no SoundEffectPlayed is posted and no delay applies. An effect the client has not loaded yet plays nothing. Game thread only; raises on a client whose table has the effect chain off.

getAmbientSoundEffects

getAmbientSoundEffects: (Client) -> AmbientSoundEffectDeque

The top-level world view's ambient sounds: the looping area sounds its locs and NPCs make. for _, effect in client:getAmbientSoundEffects() do walks them oldest first, as the client lists them when walked; client:getAmbientSoundEffects():clear() stops them all (game thread only). Walking raises on a client whose table does not place the list; clearing, on one whose table has the client's stop off.

changeMemoryMode

changeMemoryMode: (Client, boolean) -> ()

Turn the client's low detail on (or off): the client's own low-detail flag (the one its lowmem / highmem commands set), then, while logged in, the scene is loaded again (setGameState(LOADING)) so it is built under it. What it changes is the client's: a region loads with the current plane as the scene's lowest drawn level, a loc spawning on another plane is skipped, idle players are drawn without their idle animation past 50 players (200 without it), and the next login tells the server. Ground decorations stay and tile textures are not simplified (the client's low detail has neither), and the client's audio is left as it is. Game thread only; raises on a client whose table does not place the flag.

setUnlockedFps

setUnlockedFps: (Client, boolean) -> ()

Let the client draw frames apart from its 20 ms cycle: paced to setUnlockedFpsTarget's rate, or not at all until one is set (cleared by setUnlockedFps(false)). false puts the client's own frame limit back (its "FpsLimit" setting). The client already draws frames apart from its cycle, paced by its own limit, so false gives that limit; while the window is not focused the client's own background limit applies; and when the player changes the client's frame limit, the client's applies until this is called again. Game thread only; raises on a client whose table does not place the frame pacer.

setUnlockedFpsTarget

setUnlockedFpsTarget: (Client, number) -> ()

The frame rate to pace to while the FPS is unlocked (setUnlockedFps(true)); 0 or less is none. Kept while locked, and applied when unlocked. Game thread only; raises as setUnlockedFps does.

setExpandedMapLoading

setExpandedMapLoading: (Client, number) -> ()

Draw the map chunks zones (8 tiles each) past the 104 tiles the game loads, on every side: 117HD's "Expanded map loading". 0 (the default) draws only the game's own scene; 5, the most, draws 184 tiles across. What the ring adds is scenery only (ground and locs: no players, NPCs or items, which the server sends for the 104 tiles alone), it cannot be clicked, and nothing the game or a plugin reads changes: the scene, its coordinates and every event stay the game's. How far of it shows is the draw distance (Scene:setDrawDistance, up to 90 tiles). It is built from the client cycle after the call and again after each scene load, a few cycles later than the scene (its map files may first have to load). Drawn in SD only, and not in an instance. Raises outside 0..5, and on a client whose code is not the code it was written for. Game thread only.

setShouldRenderLoginScreenFire

setShouldRenderLoginScreenFire: (Client, boolean) -> ()

Whether the title screen's fire is drawn (true by default). While false the client's fire is neither drawn nor animated, wherever the client draws it (both columns of the title screen and a login interface's fire); set true again, it carries on from where it stood. true always succeeds (it is what the client does by itself); false is game thread only and raises on a client whose table does not place the fire's draw.

setAnimationInterpolationFilter

setAnimationInterpolationFilter: (Client, ((number) -> boolean)?) -> ()

Which animations the client tweens between frames (animation smoothing): players, NPCs, animated objects and the spot animations on actors whose sequence id filter answers true for are drawn moving smoothly from each frame towards the next on every frame drawn, not only once per 20 ms cycle. An actor is asked by its action (else its pose); one doing both at once, and skeletal animations, are drawn as the game draws them. nil stops all smoothing. One filter for the client: the last set, by any plugin, wins, and it is cleared when the plugin that set it stops. filter must be pure: it is asked once for every sequence id the game has, on the game thread, at the plugin's next invoke point (within a 20 ms cycle; nothing is tweened until then), not while frames are drawn, so what it reads later changes nothing. The frames between are applied unrounded, so a tweened part turns continuously, in SD and in HD. Game thread only; raises on a client whose table does not place what smoothing reads.

getAnimationInterpolationFilter

getAnimationInterpolationFilter: (Client) -> ((number) -> boolean)?

The animation smoothing filter last set (setAnimationInterpolationFilter), by any plugin, or nil while smoothing is off.

drawOriginalMenu

drawOriginalMenu: (Client, number) -> ()

Draw the client's own menu now, at alpha (0 transparent .. 255 opaque): call it from a BeforeMenuRender subscriber, then event:consume() so the client does not draw it again on top. At 255 it is the client's draw exactly; below, the menu's boxes and outlines are blended over what is under them and its text and icons stay opaque. Its rows, colours and footer blend separately, the outline's corner pixels blend twice, and an alpha outside 0..255 is clamped. Raises outside BeforeMenuRender (the menu is drawn only inside the client's draw of it), off the game thread, and on a client whose table does not place the menu draw.

getFollower

getFollower: (Client) -> NPC?

The local player's follower (a pet, a familiar, a quest follower), or nil: the first follower varp the session changed (VarPlayerID.FOLLOWER_NPC or FOLLOWER_NPC_SECONDARY, the varps the cache gives client code 17), whose low 16 bits are an NPC index in the local player's world view. Nil with no local player, before a follower varp has changed since login, while it names no NPC (-1 when there is no follower), or when that NPC is not loaded. Raises on a client whose table does not place the client's follower list.

getScriptActiveWidget

getScriptActiveWidget: (Client) -> Widget?

The widget the running script's cc_* instructions act on (the script VM's active component register: the component cc_find found or cc_create made, the one to read in ScriptPostFired after a draw script), or nil when the register is empty. Raises where the table does not place the script VM.

getFocusedInputFieldWidget

getFocusedInputFieldWidget: (Client) -> Widget?

The widget whose input field has the keyboard focus (a field the game types into instead of the chatbox), or nil when none has it.

getArray

getArray: (Client, number) -> {number}?

The running script's int array in local arrayId (the script's own array): arr[i] reads value i - 1, arr[i] = v writes it on the game thread, #arr is its length. Nil for a long or string array; raises when there is no such local, or no array in it. Read it in the ScriptCallbackEvent (or ScriptPreFired/ScriptPostFired) that hands out the id: the view finds the local again on every access, so after that script moves on it reads whatever the local holds then. Raises where the table does not place the script VM; a write also raises on a client whose table has the writes off.

closeInterface

closeInterface: (Client, WidgetNode, boolean) -> ()

Close the sub-interface interfaceNode names client-side, as the client closes one (no packet; the group unloaded when unload; WidgetClosed posted first). Raises "WidgetNode is no longer valid" when that interface is no longer open in that component. Game thread only, for example from clientThread:invokeAtTickEnd. Asked from a callback the client's own close raised (WidgetClosed, WidgetUnloaded, a sub-change script), it raises "the client is making that change itself right now": ask with clientThread:invokeLater instead. Raises on a client whose table has the close off.

openWorldHopper

openWorldHopper: (Client) -> ()

Open the world switcher, through the virtual mouse: the logout panel first when another is showing, then its "World Switcher" button. It opens a tick or two later. It gives up after three clicks, or three openings of the logout panel, that did not open it. Raises when not logged in.

getWidget

getWidget: ((Client, number) -> Widget?) & ((Client, number, number) -> Widget?)

(Client, number) -> Widget?: The widget with packed id id (group << 16 | child), or nil when its interface is not loaded. Raises when id is not an int: nil, a fraction, NaN, inf or past int32, so an id read from data needs checking before it gets here.

(Client, number, number) -> Widget?: Component childId of interface groupId, or nil when the interface is not loaded or has no such component. Raises when either is not an int, as the packed form does.

getComponentTable

getComponentTable: (Client) -> {[number]: WidgetNode}

Every open sub-interface, keyed by the component it is open in: client:getComponentTable()[componentId].

getDraggedWidget

getDraggedWidget: (Client) -> Widget?

The draggable widget a mouse press landed on (the client's clicked widget), from the press until the release, whether or not the drag has begun; nil when there is none.

getDraggedOnWidget

getDraggedOnWidget: (Client) -> Widget?

The widget under the dragged one that takes a drop (its config has WidgetConfig.DRAG_ON), as the client found it this cycle; nil when there is none.

setDraggedOnWidget

setDraggedOnWidget: (Client, Widget?) -> ()

Where the drag in progress drops (nil: nowhere, so the release sends no IF_BUTTOND). The client derives it again every cycle: set it from onWidgetDrag. A widget that is gone drops nowhere, as nil. Game thread only.

isWidgetSelected

isWidgetSelected: (Client) -> boolean

Whether a widget is in target mode: a spell or an item's "Use" is selected.

getSelectedWidget

getSelectedWidget: (Client) -> Widget?

The widget in target mode (the selected spell, or the inventory slot of a "Use" item); nil when none is, or it is gone.

setWidgetSelected

setWidgetSelected: (Client, boolean) -> ()

false turns target mode off: nothing else runs (no onTargetLeave; a plugin that changed the source widget's look restores it). true keeps target mode on when it is on already, and raises otherwise: the client has no target mode without the spell or item that started it (start one with a virtual-mouse click on it). Game thread only.

runScript

runScript: (Client, ...any) -> ()

Run clientscript args[1] with the rest as its arguments, now, on the game thread: client:runScript(id, a, b) (or the arguments as one array).

getIntStack

getIntStack: (Client) -> {number}

The script VM's int stack, the interpreter's own array. While a ScriptCallbackEvent is delivered it is that event's stacks, and a write is staged for the hook to write back after the last subscriber; anywhere else it is the VM as it is, which after runScript(...) holds the script's results from slot 0 (client:getIntStack()[1]), read-only. In a ScriptPostFired the VM as it is can be written: the top slot (stack[client:getIntStackSize()]) is what the script returns, so a write changes its answer, for example making bankmain_searching answer true (where the event is raised at the script's return; elsewhere it raises). 1-based, like every Luau array; #stack is the array's length. The same object on every call.

setIntStackSize

setIntStackSize: (Client, number) -> ()

Set the int stack's size (staged into the ScriptCallbackEvent being delivered; an error anywhere else).

getObjectStack

getObjectStack: (Client) -> { number | string }

The script VM's object stack (the strings scripts pass), as getIntStack() is the int stack: the event's while one is delivered, else the VM's, read-only.

setObjectStackSize

setObjectStackSize: (Client, number) -> ()

Set the object stack's size (staged into the ScriptCallbackEvent being delivered; an error anywhere else).

getMenu

getMenu: (Client) -> Menu

The root right-click menu (one object for the client's life).

createMenuEntry

createMenuEntry: (Client, number) -> MenuEntry

Add an entry at idx (getMenu():createMenuEntry(idx); -1 is the top).

Example
-- Add an entry while the menu is opening; it lives as long as that menu.
function plugin:onMenuOpened(_event: MenuOpened)
    client:createMenuEntry(-1)
        :setOption("Mark")
        :setTarget("this tile")
        :setType(MenuAction.CLIENT)
        :onClick(function(_entry)
            log:info("marked")
        end)
end

getMenuX

getMenuX: (Client) -> number

The open menu's left edge, canvas pixels.

addChatMessage

addChatMessage: ((Client, ChatMessageType, string, string, string?) -> MessageNode) & ((Client, ChatMessageType, string, string, string?, boolean) -> MessageNode)

(Client, ChatMessageType, string, string, string?) -> MessageNode: Add a line to the chatbox through the client's own message add (a ChatMessage is posted for it), and hand back its node. A group ironman type (CLAN_GIM_CHAT, CLAN_GIM_MESSAGE) is stored as its clan type with | before the text. Game thread only.

(Client, ChatMessageType, string, string, string?, boolean) -> MessageNode: addChatMessage, posting the ChatMessage only when postEvent is true.

refreshChat

refreshChat: (Client) -> ()

Have the chatbox rebuild its lines (after a message node was changed).

getClanSettings

getClanSettings: ((Client) -> ClanSettings?) & ((Client, number) -> ClanSettings?)

(Client) -> ClanSettings?: The player's clan's settings (its members, online or not), or nil.

(Client, number) -> ClanSettings?: Clan clanId's settings (ClanID), or nil.

isFriended

isFriended: (Client, string, boolean) -> boolean

Whether name is on the friends list (and online, when mustBeLoggedIn).

getSpriteOverrides

getSpriteOverrides: (Client) -> {[number]: SpritePixels}

The sprite overrides, sprite id to SpritePixels as a keyed table (the same table every call, shared by every plugin): t[spriteId] = sprite makes the client load sprite wherever it loads that SpriteID, t[spriteId] = nil gives the client its own back, t[spriteId] reads it, for id, sprite in t walks it. Shows at once (no cache reset is needed). A put the client cannot take (its table does not place the override sites) is an error. A remove of an id the map does not hold changes nothing and never raises.

getWidgetSpriteOverrides

getWidgetSpriteOverrides: (Client) -> {[number]: SpritePixels}

The widget sprite overrides, by packed widget id (InterfaceID), the same keyed table form: the widget draws sprite in place of its own sprite while its getSpriteId() is not -1, as the sprite is (no flips, outline or shadow).

getModIcons

getModIcons: (Client) -> {IndexedSprite}?

The chat icons <img=n> draws, as a live 1-based view of the client's array (one for every plugin): icons[n + 1] is the icon <img=n> draws, icons[i] = sprite replaces it (drawn from the next frame), #icons is the length, for i, s in icons walks it. A view, like getIntStack(): copy it with a loop (for i, s in icons do copy[i] = s end). A slot you set reads back as the sprite you set (icons[i] = s then icons[i] == s). nil before the client loaded its icons. An error on a client whose table does not place it.

setModIcons

setModIcons: (Client, {IndexedSprite}) -> ()

Make modIcons (a table of IndexedSprites) the chat icons <img=n> draws, for every plugin. Each icon is copied into the client as it is now.

getMapDots

getMapDots: (Client) -> {SpritePixels}

The minimap's dot sprites, a live 1-based view by dot id + 1 (DOT_ITEM 0 is dots[1], then DOT_NPC, DOT_PLAYER, DOT_FRIEND, DOT_TEAM, DOT_FRIENDSCHAT, DOT_CLAN): dots[i] is a copy of the sprite the minimap draws (nil before it built its dots), dots[i] = sprite makes the minimap draw sprite for that dot from the next frame. Copy it with a loop, as getModIcons(). The client's own dot colour settings rebuild a dot when they change. Reading or writing a dot raises on a client whose table does not place it.

setCompass

setCompass: (Client, SpritePixels) -> ()

Make the minimap draw compass as its compass (copied as it is now) until the next call. An error on a client whose table does not place it.

getCrossSprites

getCrossSprites: (Client) -> {SpritePixels}?

The click cross frames (4 yellow, then 4 red), as a live 1-based view of the array the client draws from (one for every plugin): crosses[i] is a copy of frame i - 1, crosses[i] = sprite makes the client draw sprite for it from the next click on, #crosses is the count, for i, s in crosses walks it. Copy it with a loop, as getMapDots(). nil before the client loaded its crosses. An error on a client whose table does not place it.

resetHealthBarCaches

resetHealthBarCaches: (Client) -> ()

Empty the client's health bar definition and sprite caches: every health bar, those already over an actor too, looks its sprites up again at its next draw, so a sprite override put since shows. An error on a client whose table does not place it.

setLoginScreen

setLoginScreen: (Client, SpritePixels?) -> ()

Draw pixels as the login screen's background (copied as it is now): wider than 765 centred, else at the login area's left, and 383 wide or less beside its mirror image. nil gives the client its own background back. It stays across logins (put back as the client reloads its title screen). An error on a client whose table does not place it.

getSprites

getSprites: (Client, IndexDataBase, number, number) -> {SpritePixels}?

Every frame of sprite group archiveId (a SpriteID), decoded now: the client's SpriteBuffer read, as spriteManager:getSprite reads one frame. nil when the client cannot read the group now (before the login screen, a group not in the cache yet) or for a fileId other than 0 (a sprite group's one file). source is client:getIndexSprites(); another index raises.

createSpritePixels

createSpritePixels: (Client, {number}, number, number) -> SpritePixels

A sprite of pixels (width * height ints, row by row, as given: getPixels() answers them back unchanged, alpha included, and 0 draws nothing).

createItemSprite

createItemSprite: (Client, number, number, number, number, number, boolean, number) -> SpritePixels?

Item itemId's inventory sprite as the client draws it (quantity, border, shadowColor, stackable mode, scale), at once on the game thread; nil when it cannot be drawn now. noted must be false (a noted item is its own id) and scale 512, else it is an error. Drawn only at the login screen or logged in: while logging in, loading or hopping this answers nil until the state is back.

getDBTableField

getDBTableField: (Client, number, number, number) -> { number | string }

DB row rowID's values in column at tuple position tupleIndex (0-based): one per tuple the row holds there, or its table's default when the row does not set the column; empty when neither does. Numbers and strings (a value past 2^53 as its decimal string). Raises "tuple index too large", and for a column the table does not have. The client's own caches, on the game thread only.

getDBRowsByValue

getDBRowsByValue: (Client, number, number, number, any) -> {number}

The rows of DB table table whose column holds value at tuple position tupleIndex (0-based), in the client's index order; empty when none does. value is a whole number (it matches an int or long column) or a string (a string column); anything else matches nothing. The client's own DB table index, loaded through its cache, on the game thread only. Raises for a tuple position the column does not have, for a table the client has no index for, and on a client whose table has the client's index getters off.

getDBTableRows

getDBTableRows: (Client, number) -> {number}?

Every row of DB table table, in the client's index order (its master index), or nil when the client has none for it. On the game thread only; raises as getDBRowsByValue does.

getMapElementConfig

getMapElementConfig: (Client, number) -> MapElementConfig

Map element definition id (the client loads them all once, at the cache load). Raises for an id past the definitions, before the load, and on a client whose table does not place the definitions.

createClientObject

createClientObject: (Client) -> ClientObject

A new client-side scene entity of this plugin, inactive, a ClientObject Drawn by the client's own scene in SD, and by its HD renderer in HD from the HD model the same recipe builds.

loadModel

loadModel: (Client, number, {number}?, {number}?) -> Model?

(Client, number) -> Model?: Cache model id, lit with ModelData's defaults; nil when the cache has no such model (the SD model in either mode). Raises off the game thread or before the client is attached.

(Client, number, {number}?, {number}?) -> Model?: Cache model id with each colorToFind[i] face colour replaced by colorToReplace[i] (HSL, a signed 16-bit value or its unsigned value), lit with ModelData's defaults; nil when the cache has no such model. A colorToReplace shorter than colorToFind raises.

loadModelData

loadModelData: (Client, number) -> ModelData?

Cache model id's data, to recolour and light; nil when the cache has no such model. Each call makes a new one, so a recolour never reaches another.

loadAnimation

loadAnimation: (Client, number) -> Animation?

Sequence id, for ClientObject:setAnimation; nil for one with no frames that is not skeletal.

getBufferProvider

getBufferProvider: (Client) -> BufferProvider?

The client's frame buffer: the canvas-sized ARGB image the client draws its whole interface into (the 3D scene is drawn on the GPU and composited under it), or nil before the client has made it. getPixels() is that buffer itself, read and written in place. Game thread only; raises on a client whose table has the frame buffer off. The handle follows the client's current buffer, so one kept across a canvas resize answers the new size and pixels.