Skip to content

List

Lists of a plugin’s things, like lights, that Wraith shows for the player to pick from. The plugin supplies items; Wraith keeps the picks and sends button presses back. Any thread.

set(items: Array<import("salamander").Given<Wraith.ItemList.Item>>): void
selected(): Array<bigint>
select(id: number | bigint): void
deselect(id: number | bigint): void
draw(): void
close(): void

Everything in it, whenever that changes. The first is the primary.

Uses ItemList.Item.

What’s picked of what’s listed, in pick order, or the default. Good till the thread’s next call into Wraith.

Picks id as the player would. With one it replaces the pick, and 0 picks nothing.

Draws it in a window of the plugin’s own. Render thread, inside a frame callback.

Gone from Wraith; picks are still kept. Fine to call twice.

Get it with Api.lists().

open(id: string, options: import("salamander").Given<Wraith.ItemList.Options>, add: Wraith.ItemList.Add | null, remove: Wraith.ItemList.Remove | null, rename: Wraith.ItemList.Rename | null): Wraith.ItemList

id is unique for the plugin: letters, digits, _, - and .. Each callback passed adds its button. Gone with the plugin.

Fails with ListError. Uses ItemList.Options, ItemList.Add, ItemList.Remove, ItemList.Rename, ItemList.

What can go wrong, besides Cancelled, Unsupported and Gone.

Code Error
1 InvalidId
2 AlreadyOpen
3 Failed

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 id u64 Stable while it’s around, like its address. Not 0
0x8 name string Picks are kept by name too, so they carry over when the id changes
0x18 detail string Shown on hover. Can be empty
0x28 current bool The one in use now, like the camera on screen
id: bigint
name: string
detail: string
current: boolean

How many the player can pick.

An enum of u8.

Value Name
0 none
1 one
2 many

A struct, 0x28 bytes, aligned to 8.

Offset Field Type
0x0 title string Defaults to the id
0x10 pick ItemList.Pick
0x11 current_by_default bool While nothing picked is listed, the current one counts as picked, else the first
0x12 remember bool Keeps picks for next time the game starts
0x18 current_label string Beside the current one, like “On screen”. Defaults to “Current”
title: string
pick: Wraith.ItemList.Pick | Wraith.ItemList.PickName
current_by_default: boolean
remember: boolean
current_label: string

The player pressed add. List the new one, and select it if it should be picked. Render thread.

Wraith.ItemList.Add

The player pressed remove on id. Render thread.

Wraith.ItemList.Remove

The player renamed id. List it again with its new name. Render thread.

Wraith.ItemList.Rename

Made with ♥ by Asgard