The avatar, den and pet editors
phantom.aj.editorThe screen and sound
The avatar, den and pet editors.
Scripts and plugins
A script has all of it, as phantom.aj.editor, and so does a plugin, from ctx.phantom(): the SDK runs in the plugin's own frame. Each call is marked with what it needs: game:read for what the area knows and hears, which "game": "read" in the manifest grants, and game:act for doing things in it as the player, which needs "game": "act" (see Permissions).
Overview
editor.avatar: The avatar editor (gui.AvatarEditor): phantom.aj.editor.avatar.
| Member | What it does | Plugins |
|---|---|---|
changes() | What saving now would send, or null when the editor is not open. | game:read |
colors() | Each colour grid: the index chosen and the indexes it offers. | game:read |
current() | The editor as it stands, in one message, or null when it is not open. | game:read |
discard() | Closes the editor without saving, as throwing an editor away does: the trade counts it had at the start are put back (TradeManager.resetNumTradeItems) and the editor goes (GuiManager.onAvEditorClose). | game:act |
isOpen() | Whether the avatar editor is open. | game:read |
items() | The clothes the editor lists, as it sorts and filters them now, with whether the animal in the editor wears each. | game:read |
lists() | How many things are in each list the editor sorted the player's things into as it opened. | game:read |
nameBar() | The name bar picker: its colours, the badges on offer, and the name bar it will save. | game:read |
open() | Opens the avatar editor on the player's animal, as the HUD's button does (GuiManager.openAvatarEditor), and resolves once its art has loaded. | game:act |
openPanel() | Opens a window over the editor as its button does: the clothes shop, the pets, the recycler or the trade picker. | game:act |
palettes() | The three palettes the grids paint from, as packed colours in wheel order. | game:read |
pickColor() | Chooses a colour for a part of the animal from its grid, by palette index, as a click on the swatch does, and resolves once the editor's animal is painted with it. | game:act |
refreshChrome() | Draws the editor's own chrome again from what it holds: the currency counts, the clean up button, every asset's visibility and the custom pattern's tint. | game:act |
save() | Saves and closes the editor, as its own close button does (onClose, sendChangesRequest), and resolves once the server has answered what was sent and the editor is gone. | game:act |
scroll() | Where the list shown is scrolled; null when it is not built. | game:read |
scrollTo() | Scrolls the clothes list to show the item at index. | game:act |
search() | Filters the clothes by a search, as typing in the search bar does; empty text clears it. | game:act |
showList() | Shows the clothes or the trade list, as their buttons do. | game:act |
showTab() | Shows one of the colour tabs (openTab), and resolves once the editor has it open. | game:act |
sort() | Sorts the clothes as the sort popup's buttons do; time pressed when already sorted by time turns the list oldest first, as the client does. | game:act |
stepBodyMod() | Steps the pattern or the eyes, whichever tab is open, as its arrows do; resolves with the choice. | game:act |
takeOff() | Takes one of the clothes off the animal in the editor, as clicking its window does. | game:act |
takeOffAll() | Takes everything off the animal in the editor, as the clean up button's yes does. | game:act |
trade() | The trade list the editor is building. | game:read |
wear() | Puts one of the clothes on the animal in the editor, as clicking its window does, and resolves with the item once the editor wears it. | game:act |
onAnswer() | Hears the server's answers to a save as the editor takes them: items, colours, applied. | game:read |
onBodyMod() | Hears the pattern or eyes stepped by the arrows. | game:read |
onButton() | Hears the player's mouse on the editor's own buttons: presses, and with hover the mouse moving over and off them too. | game:read |
onClose() | Hears the editor go (destroy), saved or not. | game:read |
onColor() | Hears a colour chosen in one of the grids (onColorChanged). | game:read |
onItem() | Hears something put on (showItem) or taken off (hideItem) in the editor. | game:read |
onItemPress() | Hears a press on an item window (winMouseClick), or on one only members may wear. | game:read |
onList() | Hears the list drawn again (createItemWindows): switched, sorted or searched. | game:read |
onOpen() | Hears the editor open (init), before its art has loaded. | game:read |
onPanel() | Hears a window over the editor go up or come down: the shop, the pets, the recycler, the trade picker. | game:read |
onReady() | Hears the editor's art land (onMediaItemLoaded): everything in it is there from now on. | game:read |
onSave() | Hears the editor begin to save (sendChangesRequest), with what it is sending. | game:read |
onStep() | Hears what the editor does of its own: an item taken off to make room (swap), the trade list changed (trade), a mannequin's item moved (mannequinMove), its art loading (art). | game:read |
onTab() | Hears a colour tab opened (openTab). | game:read |
editor.petCreator: The pet creator (gui.PetCreator, PetManager._petFinder): phantom.aj.editor.petCreator.
| Member | What it does | Plugins |
|---|---|---|
adopt() | Adopts the pet the creator built, as saying yes to its adopt button's question does (onAdoptYesBtn, which sends pc, or the diamond shop's pb), and resolves with the pet once the server has made it. | game:act |
back() | Goes back a screen, as its back button does. | game:act |
choices() | The pets it offers for the world the player is in. | game:act |
choose() | Chooses one of the pets offered, by its kind, as clicking its window does. | game:act |
close() | Closes the creator without adopting, as its close button does. | game:act |
closeNotice() | Closes whichever notice is up over the creator (too little to pay, a pet that was won). | game:act |
current() | The pet creator as it stands, in one message, or null when it is not open. | game:read |
isOpen() | Whether the pet creator is open. | game:read |
nameChoices() | The halves of a name each wheel offers, in order; null before the wheels are built. | game:read |
next() | Moves on to the next screen, as its next button does; resolves with the screen it is on. | game:act |
pickColor() | Chooses a colour on one of the two wheels, by palette index, as a click on its swatch does. | game:act |
pickEye() | Chooses a pair of eyes, from 1, as clicking its window on the eyes tab does. | game:act |
randomise() | Gives the pet a random look, as the randomise button does, and resolves with it once the creator has finished drawing it (the button lights again). | game:act |
rollName() | Pulls the name lever, as the player does, and resolves with the name once both wheels stop. | game:act |
setName() | Sets the name from the two wheels' lists, by place in each (nameChoices), and resolves with the name the creator shows. | game:act |
setTrait() | Sets one of the traits to a choice, from 1, by the fewest presses of its arrows. | game:act |
showTab() | Shows one of the customise screen's tabs (openTab). | game:act |
stepTrait() | Steps one of the three traits (1 to 3), as its arrows do; resolves with where it is. | game:act |
wheel() | One colour wheel: the index chosen and the indexes it offers. | game:read |
onButton() | Hears the player's mouse on the creator's own buttons; with hover, over and off too. | game:read |
onClose() | Hears the creator close, and whether a pet was made. | game:read |
onCreated() | Hears the creator take the server's answer to an adopt (onCreateResponse). | game:read |
onLook() | Hears the pet shown change: another kind chosen, a colour, its art landing. | game:read |
onName() | Hears the name change, as either wheel stops or the wheels are filled. | game:read |
onOpen() | Hears the creator open (init). | game:read |
onReady() | Hears its list of pets built (filterItemLists): it can be used from now on. | game:read |
onStep() | Hears the creator move between its screens. | game:read |
onTraits() | Hears the eyes or a trait chosen. | game:read |
editor.avatar
The avatar editor (gui.AvatarEditor): phantom.aj.editor.avatar. Its tabs, its clothes and colour grids, the trade list and the name bar it builds, all as the player works it. Nothing it does reaches the server until it is saved: save closes it as its own close does and resolves once the server has answered.
await phantom.aj.editor.avatar.open();
const [first] = await phantom.aj.editor.avatar.items();
if (first && !first.worn) await phantom.aj.editor.avatar.wear(first.invIdx);
await phantom.aj.editor.avatar.save();changes
changes() => Promise<AvatarEditorChanges | null>What saving now would send, or null when the editor is not open.
Returns
Promise<AvatarEditorChanges \| null>
Types
colors
colors() => Promise<Record<AvatarColorPart, EditorColorGrid> | null>Each colour grid: the index chosen and the indexes it offers. Null before the grids are built.
Returns
Promise<Record<AvatarColorPart, EditorColorGrid> \| null>
current
current() => Promise<AvatarEditorState | null>The editor as it stands, in one message, or null when it is not open.
Returns
Promise<AvatarEditorState \| null>
Types
discard
discard(options?: ActOptions) => Promise<void>Closes the editor without saving, as throwing an editor away does: the trade counts it had at the start are put back (TradeManager.resetNumTradeItems) and the editor goes (GuiManager.onAvEditorClose).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
isOpen
isOpen() => Promise<boolean>Whether the avatar editor is open.
Returns
Promise<boolean>
items
items(options?: EditorListOptions) => Promise<AvatarEditorItem[]>The clothes the editor lists, as it sorts and filters them now, with whether the animal in the editor wears each. Empty when the editor is not open.
Parameters
| Name | Type | |
|---|---|---|
options optional | EditorListOptions |
Returns
Promise<AvatarEditorItem[]>
Types
lists
lists() => Promise<AvatarEditorLists | null>How many things are in each list the editor sorted the player's things into as it opened.
Returns
Promise<AvatarEditorLists \| null>
Types
nameBar
nameBar() => Promise<AvatarEditorNameBar | null>The name bar picker: its colours, the badges on offer, and the name bar it will save.
Returns
Promise<AvatarEditorNameBar \| null>
Types
open
open(options?: ActOptions) => Promise<AvatarEditorState>Opens the avatar editor on the player's animal, as the HUD's button does (GuiManager.openAvatarEditor), and resolves once its art has loaded. At once when it is open already. TIMEOUT after 20 seconds by default.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<AvatarEditorState>
Types
openPanel
openPanel(panel: AvatarEditorPanel, options?: ActOptions) => Promise<void>Opens a window over the editor as its button does: the clothes shop, the pets, the recycler or the trade picker. Opening the shop or the recycler saves the editor first, as the client does. Resolves once the window is there.
Parameters
| Name | Type | |
|---|---|---|
panel | AvatarEditorPanel | |
options optional | ActOptions |
Returns
Promise<void>
Types
palettes
palettes() => Promise<AvatarEditorPalettes | null>The three palettes the grids paint from, as packed colours in wheel order.
Returns
Promise<AvatarEditorPalettes \| null>
Types
pickColor
pickColor(part: AvatarColorPart, index: number, options?: ActOptions) => Promise<void>Chooses a colour for a part of the animal from its grid, by palette index, as a click on the swatch does, and resolves once the editor's animal is painted with it.
Parameters
| Name | Type | |
|---|---|---|
part | AvatarColorPart | |
index | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
refreshChrome
refreshChrome(options?: ActOptions) => Promise<void>Draws the editor's own chrome again from what it holds: the currency counts, the clean up button, every asset's visibility and the custom pattern's tint.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
save
save(options?: ActOptions) => Promise<AvatarEditorSaved>Saves and closes the editor, as its own close button does (onClose, sendChangesRequest), and resolves once the server has answered what was sent and the editor is gone. Throws REFUSED when the server would not take the items or the colours, or when the close button is greyed out (the tutorial's first look).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<AvatarEditorSaved>
Types
scroll
scroll() => Promise<EditorScroll | null>Where the list shown is scrolled; null when it is not built.
Returns
Promise<EditorScroll \| null>
Types
scrollTo
scrollTo(index: number, options?: ActOptions) => Promise<EditorScroll>Scrolls the clothes list to show the item at index.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<EditorScroll>
Types
search
search(text: string, options?: ActOptions) => Promise<void>Filters the clothes by a search, as typing in the search bar does; empty text clears it.
Parameters
| Name | Type | |
|---|---|---|
text | string | |
options optional | ActOptions |
Returns
Promise<void>
Types
showList
showList(list: AvatarEditorList, options?: ActOptions) => Promise<void>Shows the clothes or the trade list, as their buttons do.
Parameters
| Name | Type | |
|---|---|---|
list | AvatarEditorList | |
options optional | ActOptions |
Returns
Promise<void>
Types
showTab
showTab(tab: AvatarEditorTab, options?: ActOptions) => Promise<void>Shows one of the colour tabs (openTab), and resolves once the editor has it open.
Parameters
| Name | Type | |
|---|---|---|
tab | AvatarEditorTab | |
options optional | ActOptions |
Returns
Promise<void>
Types
sort
sort(by: AvatarEditorSort, options?: ActOptions) => Promise<{ by: AvatarEditorSort; oldestFirst: boolean; }>Sorts the clothes as the sort popup's buttons do; time pressed when already sorted by time turns the list oldest first, as the client does.
Parameters
| Name | Type | |
|---|---|---|
by | AvatarEditorSort | |
options optional | ActOptions |
Returns
Promise<{ by: AvatarEditorSort; oldestFirst: boolean; }>
Types
stepBodyMod
stepBodyMod(direction: "next" | "previous", options?: ActOptions) => Promise<EditorChoice>Steps the pattern or the eyes, whichever tab is open, as its arrows do; resolves with the choice.
Parameters
| Name | Type | |
|---|---|---|
direction | "next" | "previous" | |
options optional | ActOptions |
Returns
Promise<EditorChoice>
Types
takeOff
takeOff(invIdx: number, options?: ActOptions) => Promise<AvatarEditorItem>Takes one of the clothes off the animal in the editor, as clicking its window does.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<AvatarEditorItem>
Types
takeOffAll
takeOffAll(options?: ActOptions) => Promise<void>Takes everything off the animal in the editor, as the clean up button's yes does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
trade
trade() => Promise<AvatarEditorTrade | null>The trade list the editor is building.
Returns
Promise<AvatarEditorTrade \| null>
Types
wear
wear(invIdx: number, options?: ActOptions) => Promise<AvatarEditorItem>Puts one of the clothes on the animal in the editor, as clicking its window does, and resolves with the item once the editor wears it. Nothing is sent until save. Throws REFUSED for an item the editor does not list or will not put on (members only, the wrong animal).
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<AvatarEditorItem>
Types
onAnswer
onAnswer(listener: (answer: AvatarEditorAnswer) => void) => () => voidHears the server's answers to a save as the editor takes them: items, colours, applied.
Parameters
| Name | Type | |
|---|---|---|
listener | (answer: AvatarEditorAnswer) => void |
Returns
() => void. Call it to stop listening.
Types
onBodyMod
onBodyMod(listener: (change: { tab: "eyes" | "patterns"; choice: EditorChoice; }) => void) => () => voidHears the pattern or eyes stepped by the arrows.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: { tab: "eyes" | "patterns"; choice: EditorChoice; }) => void |
Returns
() => void. Call it to stop listening.
Types
onButton
onButton(listener: (event: EditorButtonEvent<AvatarEditorButton>) => void, options?: EditorButtonOptions) => () => voidHears the player's mouse on the editor's own buttons: presses, and with hover the mouse moving over and off them too.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: EditorButtonEvent<AvatarEditorButton>) => void | |
options optional | EditorButtonOptions |
Returns
() => void. Call it to stop listening.
Types
EditorButtonEvent · EditorMouseAction · AvatarEditorButton · EditorButtonOptions
Example
phantom.aj.editor.avatar.onButton(({ button, which }) => console.log(button, which));onClose
onClose(listener: () => void) => () => voidHears the editor go (destroy), saved or not.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onColor
onColor(listener: (change: { part: AvatarColorPart; index: number; }) => void) => () => voidHears a colour chosen in one of the grids (onColorChanged).
Parameters
| Name | Type | |
|---|---|---|
listener | (change: { part: AvatarColorPart; index: number; }) => void |
Returns
() => void. Call it to stop listening.
Types
onItem
onItem(listener: (change: AvatarEditorItemChange) => void) => () => voidHears something put on (showItem) or taken off (hideItem) in the editor.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: AvatarEditorItemChange) => void |
Returns
() => void. Call it to stop listening.
Types
onItemPress
onItemPress(listener: (press: AvatarEditorItemPress) => void) => () => voidHears a press on an item window (winMouseClick), or on one only members may wear.
Parameters
| Name | Type | |
|---|---|---|
listener | (press: AvatarEditorItemPress) => void |
Returns
() => void. Call it to stop listening.
Types
onList
onList(listener: (list: AvatarEditorList) => void) => () => voidHears the list drawn again (createItemWindows): switched, sorted or searched.
Parameters
| Name | Type | |
|---|---|---|
listener | (list: AvatarEditorList) => void |
Returns
() => void. Call it to stop listening.
Types
onOpen
onOpen(listener: () => void) => () => voidHears the editor open (init), before its art has loaded.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onPanel
onPanel(listener: (change: AvatarEditorPanelChange) => void) => () => voidHears a window over the editor go up or come down: the shop, the pets, the recycler, the trade picker.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: AvatarEditorPanelChange) => void |
Returns
() => void. Call it to stop listening.
Types
onReady
onReady(listener: () => void) => () => voidHears the editor's art land (onMediaItemLoaded): everything in it is there from now on.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onSave
onSave(listener: (changes: AvatarEditorChanges) => void) => () => voidHears the editor begin to save (sendChangesRequest), with what it is sending.
Parameters
| Name | Type | |
|---|---|---|
listener | (changes: AvatarEditorChanges) => void |
Returns
() => void. Call it to stop listening.
Types
onStep
onStep(listener: (step: AvatarEditorStep) => void) => () => voidHears what the editor does of its own: an item taken off to make room (swap), the trade list changed (trade), a mannequin's item moved (mannequinMove), its art loading (art).
Parameters
| Name | Type | |
|---|---|---|
listener | (step: AvatarEditorStep) => void |
Returns
() => void. Call it to stop listening.
Types
onTab
onTab(listener: (tab: AvatarEditorTab) => void) => () => voidHears a colour tab opened (openTab).
Parameters
| Name | Type | |
|---|---|---|
listener | (tab: AvatarEditorTab) => void |
Returns
() => void. Call it to stop listening.
Types
editor.petCreator
The pet creator (gui.PetCreator, PetManager._petFinder): phantom.aj.editor.petCreator. Its three screens (choose a pet, customise it, name it), its tabs, wheels and traits, and adopting what it built, as the player works it. Adopting a pet without the screen is phantom.aj.player.pets.adopt.
const creator = phantom.aj.editor.petCreator;
await creator.next();
await creator.pickColor('color1', 12);
await creator.next();
await creator.rollName();
const pet = await creator.adopt();adopt
adopt(options?: ActOptions) => Promise<PetCreatorAdopted>Adopts the pet the creator built, as saying yes to its adopt button's question does (onAdoptYesBtn, which sends pc, or the diamond shop's pb), and resolves with the pet once the server has made it. The checks the button makes first are made here and throw REFUSED: a members-only pet for a non-member, too little to pay with, no room for another.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetCreatorAdopted>
Types
back
back(options?: ActOptions) => Promise<PetCreatorStep>Goes back a screen, as its back button does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetCreatorStep>
Types
choices
choices(options?: EditorListOptions) => Promise<PetCreatorChoice[]>The pets it offers for the world the player is in.
Parameters
| Name | Type | |
|---|---|---|
options optional | EditorListOptions |
Returns
Promise<PetCreatorChoice[]>
Types
choose
choose(defId: number, options?: ActOptions) => Promise<PetCreatorLook>Chooses one of the pets offered, by its kind, as clicking its window does.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options optional | ActOptions |
Returns
Promise<PetCreatorLook>
Types
close
close(options?: ActOptions) => Promise<void>Closes the creator without adopting, as its close button does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
closeNotice
closeNotice(options?: ActOptions) => Promise<void>Closes whichever notice is up over the creator (too little to pay, a pet that was won).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<PetCreatorState | null>The pet creator as it stands, in one message, or null when it is not open.
Returns
Promise<PetCreatorState \| null>
Types
PetCreatorState · PetCreatorLook · PetCreatorTraits · PetCreatorOption · PetCreatorPrice · PetCreatorCurrency · PetCreatorName
isOpen
isOpen() => Promise<boolean>Whether the pet creator is open.
Returns
Promise<boolean>
nameChoices
nameChoices() => Promise<{ first: string[]; second: string[]; } | null>The halves of a name each wheel offers, in order; null before the wheels are built.
Returns
Promise<{ first: string[]; second: string[]; } \| null>
next
next(options?: ActOptions) => Promise<PetCreatorStep>Moves on to the next screen, as its next button does; resolves with the screen it is on.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetCreatorStep>
Types
pickColor
pickColor(wheel: PetCreatorWheel, index: number, options?: ActOptions) => Promise<PetCreatorLook>Chooses a colour on one of the two wheels, by palette index, as a click on its swatch does.
Parameters
| Name | Type | |
|---|---|---|
wheel | PetCreatorWheel | |
index | number | |
options optional | ActOptions |
Returns
Promise<PetCreatorLook>
Types
pickEye
pickEye(choice: number, options?: ActOptions) => Promise<PetCreatorOption>Chooses a pair of eyes, from 1, as clicking its window on the eyes tab does.
Parameters
| Name | Type | |
|---|---|---|
choice | number | |
options optional | ActOptions |
Returns
Promise<PetCreatorOption>
Types
randomise
randomise(options?: ActOptions) => Promise<PetCreatorLook>Gives the pet a random look, as the randomise button does, and resolves with it once the creator has finished drawing it (the button lights again).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetCreatorLook>
Types
rollName
rollName(options?: ActOptions) => Promise<PetCreatorName>Pulls the name lever, as the player does, and resolves with the name once both wheels stop.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<PetCreatorName>
Types
setName
setName(first: number, second: number, options?: ActOptions) => Promise<PetCreatorName>Sets the name from the two wheels' lists, by place in each (nameChoices), and resolves with the name the creator shows.
Parameters
| Name | Type | |
|---|---|---|
first | number | |
second | number | |
options optional | ActOptions |
Returns
Promise<PetCreatorName>
Types
setTrait
setTrait(trait: 1 | 2 | 3, choice: number, options?: ActOptions) => Promise<PetCreatorOption>Sets one of the traits to a choice, from 1, by the fewest presses of its arrows.
Parameters
| Name | Type | |
|---|---|---|
trait | 1 | 2 | 3 | |
choice | number | |
options optional | ActOptions |
Returns
Promise<PetCreatorOption>
Types
showTab
showTab(tab: PetCreatorTab, options?: ActOptions) => Promise<void>Shows one of the customise screen's tabs (openTab).
Parameters
| Name | Type | |
|---|---|---|
tab | PetCreatorTab | |
options optional | ActOptions |
Returns
Promise<void>
Types
stepTrait
stepTrait(trait: 1 | 2 | 3, direction: "next" | "previous", options?: ActOptions) => Promise<PetCreatorOption>Steps one of the three traits (1 to 3), as its arrows do; resolves with where it is.
Parameters
| Name | Type | |
|---|---|---|
trait | 1 | 2 | 3 | |
direction | "next" | "previous" | |
options optional | ActOptions |
Returns
Promise<PetCreatorOption>
Types
wheel
wheel(wheel: PetCreatorWheel) => Promise<EditorColorGrid | null>One colour wheel: the index chosen and the indexes it offers. Null before it is built.
Parameters
| Name | Type | |
|---|---|---|
wheel | PetCreatorWheel |
Returns
Promise<EditorColorGrid \| null>
Types
onButton
onButton(listener: (event: EditorButtonEvent<PetCreatorButton>) => void, options?: EditorButtonOptions) => () => voidHears the player's mouse on the creator's own buttons; with hover, over and off too.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: EditorButtonEvent<PetCreatorButton>) => void | |
options optional | EditorButtonOptions |
Returns
() => void. Call it to stop listening.
Types
onClose
onClose(listener: (created: boolean) => void) => () => voidHears the creator close, and whether a pet was made.
Parameters
| Name | Type | |
|---|---|---|
listener | (created: boolean) => void |
Returns
() => void. Call it to stop listening.
onCreated
onCreated(listener: (created: boolean) => void) => () => voidHears the creator take the server's answer to an adopt (onCreateResponse).
Parameters
| Name | Type | |
|---|---|---|
listener | (created: boolean) => void |
Returns
() => void. Call it to stop listening.
onLook
onLook(listener: (look: PetCreatorLook) => void) => () => voidHears the pet shown change: another kind chosen, a colour, its art landing.
Parameters
| Name | Type | |
|---|---|---|
listener | (look: PetCreatorLook) => void |
Returns
() => void. Call it to stop listening.
Types
onName
onName(listener: (name: string) => void) => () => voidHears the name change, as either wheel stops or the wheels are filled.
Parameters
| Name | Type | |
|---|---|---|
listener | (name: string) => void |
Returns
() => void. Call it to stop listening.
onOpen
onOpen(listener: () => void) => () => voidHears the creator open (init).
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onReady
onReady(listener: () => void) => () => voidHears its list of pets built (filterItemLists): it can be used from now on.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onStep
onStep(listener: (step: PetCreatorStep) => void) => () => voidHears the creator move between its screens.
Parameters
| Name | Type | |
|---|---|---|
listener | (step: PetCreatorStep) => void |
Returns
() => void. Call it to stop listening.
Types
onTraits
onTraits(listener: (traits: PetCreatorTraits) => void) => () => voidHears the eyes or a trait chosen.
Parameters
| Name | Type | |
|---|---|---|
listener | (traits: PetCreatorTraits) => void |
Returns
() => void. Call it to stop listening.
Types
Types
The types the calls above take and give, with every field. Import any of them in a plugin from @phantomclient/plugin/sdk, or use them as they are in a script.
AvatarEditorState
The avatar editor as it stands.
| Field | Type | |
|---|---|---|
ready | boolean | Whether its art has loaded and it can be used (avEditor). |
tab | AvatarEditorTab | null | |
list | AvatarEditorList | null | Null until the art has loaded. |
sorting | { by: AvatarEditorSort; oldestFirst: boolean; } | null | Which sort button was pressed last, and whether time was pressed twice (oldest first). |
search | string | What the search bar holds; empty for no search. |
pattern | EditorChoice | The pattern and eyes chosen, out of how many (_currPattern, _currEye). An ordinary animal's pattern 0 is none at all: the client puts a null at the head of the list. |
eye | EditorChoice | |
clothes | { count: number; max: number; } | The clothes this animal can wear in this room, and the most the account may own. |
inTutorial | boolean | Opened by the tutorial (_isFFM), which hides most of its buttons. |
forMannequin | boolean | Dressing a den mannequin rather than the player (_isForMannequin). |
panels | Record<AvatarEditorPanel, boolean> | The windows open over the editor. |
saving | boolean | Saved and waiting on the server's answer (_waitForIuResponse, _waitForApResponse). |
EditorChoice
One place in a list of things to choose between, and how many there are.
| Field | Type | |
|---|---|---|
index | number | |
count | number |
EditorListOptions
How much of one of the editors' lists to read.
| Field | Type | |
|---|---|---|
skip optional | number | undefined | Items to pass over first. |
limit optional | number | undefined | At most this many items; the whole list when left out. |
AvatarEditorItem
One of the clothes the avatar editor lists.
| Field | Type | |
|---|---|---|
index | number | Its place in the list as sorted now, which is the number its window carries. |
invIdx | number | The item in the player's inventory (Item.invIdx). |
defId | number | |
name | string | null | |
kind | "clothing" | "body" | clothing for something worn, body for a pattern or a pair of eyes (Item.type). |
worn | boolean | Whether the animal in the editor wears it now (Item.getInUse), as the editor has it: it turns the moment the item is clicked, and nothing is sent until the editor is saved. |
AvatarEditorChanges
What the avatar editor would save if it were closed now.
| Field | Type | |
|---|---|---|
putOn | number[] | The invIdx of everything put on since it opened (_itemIdsOn). |
takenOff | number[] | And taken off (_itemIdsOff). |
colors | PackedColors | The animal's colours in the editor (_avatarEditorView.colors). |
savedColors | PackedColors | The colours the animal in the room still has (_worldAvatar.colors). |
unsaved | boolean | Whether saving would send anything: items, or colours that differ. |
PackedColors
An animal's colours as the client packs them in Avatar.colors: three 32-bit words.
| Field | Type | |
|---|---|---|
0 | number | |
1 | number | |
2 | number | |
length | 3 | |
toString | () => string | Returns a string representation of an array. |
toLocaleString | { (): string; (locales: string | string[], options?: (NumberFormatOptions & DateTimeFormatOptions) | undefined): string; } | Returns a string representation of an array. The elements are converted to string using their toLocaleString methods. |
concat | { (...items: ConcatArray<number>[]): number[]; (...items: (number | ConcatArray<number>)[]): number[]; } | Combines two or more arrays. |
join | (separator?: string | undefined) => string | Adds all the elements of an array separated by the specified separator string. |
slice | (start?: number | undefined, end?: number | undefined) => number[] | Returns a section of an array. |
indexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the first occurrence of a value in an array. |
lastIndexOf | (searchElement: number, fromIndex?: number | undefined) => number | Returns the index of the last occurrence of a specified value in an array. |
every | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): boolean; } | Determines whether all the members of an array satisfy the specified test. |
some | (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any) => boolean | Determines whether the specified callback function returns true for any element of an array. |
forEach | (callbackfn: (value: number, index: number, array: readonly number[]) => void, thisArg?: any) => void | Performs the specified action for each element in an array. |
map | <U>(callbackfn: (value: number, index: number, array: readonly number[]) => U, thisArg?: any) => U[] | Calls a defined callback function on each element of an array, and returns an array that contains the results. |
filter | { <S extends number>(predicate: (value: number, index: number, array: readonly number[]) => value is S, thisArg?: any): S[]; (predicate: (value: number, index: number, array: readonly number[]) => unknown, thisArg?: any): number[]; } | Returns the elements of an array that meet the condition specified in a callback function. |
reduce | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
reduceRight | { (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number): number; (callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: readonly number[]) => number, initialValue: number): number; <U>(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: readonly number[]) => U, initialValue: U): U; } | Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. |
find | { <S extends number>(predicate: (value: number, index: number, obj: readonly number[]) => value is S, thisArg?: any): S | undefined; (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any): number | undefined; } | Returns the value of the first element in the array where predicate is true, and undefined otherwise. |
findIndex | (predicate: (value: number, index: number, obj: readonly number[]) => unknown, thisArg?: any) => number | Returns the index of the first element in the array where predicate is true, and -1 otherwise. |
entries | () => ArrayIterator<[number, number]> | Returns an iterable of key, value pairs for every entry in the array |
keys | () => ArrayIterator<number> | Returns an iterable of keys in the array |
values | () => ArrayIterator<number> | Returns an iterable of values in the array |
includes | (searchElement: number, fromIndex?: number | undefined) => boolean | Determines whether an array includes a certain element, returning true or false as appropriate. |
flatMap | <U, This = undefined>(callback: (this: This, value: number, index: number, array: number[]) => U | readonly U[], thisArg?: This | undefined) => U[] | Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1. |
flat | <A, D extends number = 1>(this: A, depth?: D | undefined) => FlatArray<A, D>[] | Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth. |
at | (index: number) => number | undefined | Returns the item located at the specified index. |
__@iterator@147944 | () => ArrayIterator<number> | Iterator of values in the array. |
__@unscopables@147954 | { readonly [x: number]: boolean | undefined; readonly length?: boolean | undefined; toString?: boolean | undefined; toLocaleString?: boolean | undefined; concat?: boolean | undefined; join?: boolean | undefined; slice?: boolean | undefined; indexOf?: boolean | undefined; lastIndexOf?: boolean | undefined; every?: boolean | undefined; some?: boolean | undefined; forEach?: boolean | undefined; map?: boolean | undefined; filter?: boolean | undefined; reduce?: boolean | undefined; reduceRight?: boolean | undefined; find?: boolean | undefined; findIndex?: boolean | undefined; entries?: boolean | undefined; keys?: boolean | undefined; values?: boolean | undefined; includes?: boolean | undefined; flatMap?: boolean | undefined; flat?: boolean | undefined; at?: boolean | undefined; [Symbol.iterator]?: boolean | undefined; readonly [Symbol.unscopables]?: boolean | undefined; } | Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. |
AvatarEditorPalettes
The three palettes the avatar editor paints from, as packed colours in wheel order.
| Field | Type | |
|---|---|---|
game | number[] | |
colour1 | number[] | |
colour2 | number[] |
AvatarEditorLists
The lists AvatarEditor.init sorted the player's things into, counted.
| Field | Type | |
|---|---|---|
head | number | |
neck | number | |
back | number | |
legs | number | |
tail | number | |
pets | number | |
denItems | number | |
inRoom | number | |
inRoomOldest | number | |
byItem | number | |
allClothes | number | |
allNewest | number | |
allOldest | number | |
allHead | number | |
allNeck | number | |
allBack | number | |
allLegs | number | |
allTail | number | |
allByItem | number | |
denNewest | number | |
denOldest | number | |
denFloor | number | |
denThemes | number | |
denByItem | number |
AvatarEditorTrade
The trade list the avatar editor is building; nothing goes to the server until it saves.
| Field | Type | |
|---|---|---|
listed | number | On the trade list now (_currTradesArray). |
added | number | Added and taken off since the editor opened (_tradeItemsIn, _tradeItemsOut). |
removed | number | |
view | "den" | "clothes" | Which list the trade view shows; the client remembers it between editors. |
picking | boolean | Whether the trade picker is open over the editor. |
requestWaiting | boolean | A trade list change waiting on the items' answer (_sendDelayedTradeRequest). |
gridBuilt | boolean | Whether the trade view's grid is built. |
atOpen | { clothes: number; denItems: number; pets: number; } | What the trade list held as the editor opened, which a discard puts back. |
AvatarEditorNameBar
The name bar picker inside the avatar editor.
| Field | Type | |
|---|---|---|
colours | string[] | The colour buttons on offer, by the client's own names (_nameBars). |
badgeMediaIds | number[] | The media id of each badge on offer (_namebarBadgeMediaIds). |
badges | number | |
badgeIconsIn | number | |
gridBuilt | boolean | |
gridHeight | number | |
data | number | The name bar the editor will save (_nameBarData, packed as UserInfo.nameBarData). |
EditorScroll
Where one of the editors' lists is scrolled to (WindowAndScrollbarGenerator).
| Field | Type | |
|---|---|---|
position | number | How far the list is scrolled (scrollYValue). |
length | number | How long the whole list is, in the same measure (scrollContentHeight). |
windows | number | How many windows the list has, empty ones included (totalNumWindows). |
perScreen | number | How many of them show at once (numWindowsPerScreen). |
ActOptions
How long something that acts may take, and what may end it first.
| Field | Type | |
|---|---|---|
timeoutMs optional | number | undefined | 10 seconds by default. |
signal optional | AbortSignal | undefined |
AvatarEditorSaved
What saving the avatar editor came to.
| Field | Type | |
|---|---|---|
changes | AvatarEditorChanges | What was saved, read as the editor began to save. |
items | boolean | null | Whether the server took the items (iu); null when none were sent. |
colors | boolean | null | Whether it took the colours and name bar (ap); null when none were sent. |
AvatarEditorTab
One of the avatar editor's colour tabs (_tabOpenId).
type AvatarEditorTab = 'colors' | 'patterns' | 'eyes'AvatarEditorList
Which of the avatar editor's two lists is up: the animal's clothes, or the trade list.
type AvatarEditorList = 'clothes' | 'trade'AvatarEditorSort
What the avatar editor's clothes are sorted by, one per button of its sort popup.
type AvatarEditorSort = 'time' | 'tail' | 'legs' | 'back' | 'neck' | 'head'AvatarColorPart
A part of the animal the avatar editor colours, each with a grid of its own.
type AvatarColorPart = 'color1' | 'color2' | 'eyes' | 'pattern'AvatarEditorPanel
A window the avatar editor opens over itself.
type AvatarEditorPanel = 'shop' | 'pets' | 'recycle' | 'tradePicker'AvatarEditorItemChange
One thing put on or taken off in the avatar editor.
| Field | Type | |
|---|---|---|
action | "wear" | "takeOff" | |
kind | "clothing" | "body" | |
invIdx | number | |
defId | number | |
name | string | null |
AvatarEditorItemPress
A press on one of the avatar editor's item windows.
| Field | Type | |
|---|---|---|
index | number | null | Where the window sits in the list shown. |
invIdx | number | null | The inventory slot of the thing in it. |
memberOnly | boolean | A press on something only members may wear (memberOnlyDown). |
confirmed | boolean | The second press, after the player agreed to take an item off a mannequin. |
AvatarEditorPanelChange
A window over the avatar editor going up or coming down.
| Field | Type | |
|---|---|---|
panel | AvatarEditorPanel | |
open | boolean | |
changed | boolean | Whether anything came of it: bought, recycled, or an item chosen. |
AvatarEditorStep
Something the avatar editor did of its own, as it happened.
type AvatarEditorStep = | { step: 'swap'; kind: 'clothes' | 'bodyMod'; invIdx: number | null; name: string | null }
| { step: 'trade'; adding: boolean; invIdx: number | null; itemType: number | null }
| { step: 'mannequinMove'; agreed: boolean }
| {
step: 'art';
part: 'badges' | 'badgeGrid' | 'badgeIcon' | 'customIcon' | 'petDrawing' | 'petLoaded';
}AvatarEditorAnswer
An answer from the server to what the avatar editor saved.
| Field | Type | |
|---|---|---|
what | "items" | "colors" | "applied" | items (iu), colors (ap), or applied, the editor taking the items' answer in. |
ok | boolean |
EditorButtonEvent
One thing the mouse did to one of an editor's own buttons.
| Field | Type | |
|---|---|---|
action | EditorMouseAction | |
button | Button | |
which | string | number | null | Which of a row: a tab, a sort, a den category, a name bar colour or badge, an eye or trait. |
grey | boolean | The client had it greyed, so the press did nothing. |
target | string | null | The button's own name in the client's art. |
EditorMouseAction
What the mouse did.
type EditorMouseAction = 'press' | 'over' | 'out'AvatarEditorButton
type AvatarEditorButton = | 'close'
| 'tab'
| 'sort'
| 'sortBy'
| 'clothes'
| 'trade'
| 'previous'
| 'next'
| 'shop'
| 'pets'
| 'recycle'
| 'search'
| 'cleanUp'
| 'tradeInfo'
| 'tradeHelpClose'
| 'trophy'
| 'gems'
| 'nameBar'
| 'nameBarClose'
| 'nameBarColor'
| 'nameBarLevel'
| 'nameBarBadge'
| 'backdrop'
| 'nameBarBackdrop'EditorButtonOptions
Whether to hear the mouse moving over buttons as well as pressing them.
| Field | Type | |
|---|---|---|
hover optional | boolean | undefined |
PetCreatorState
The pet creator as it stands.
| Field | Type | |
|---|---|---|
ready | boolean | Whether its list of pets is built (_currEnviroPetItems). |
step | PetCreatorStep | null | |
tab | PetCreatorTab | null | |
look | PetCreatorLook | |
traits | PetCreatorTraits | null | |
price | PetCreatorPrice | null | Null before a pet is chosen. |
name | PetCreatorName | null | Null before the name wheels are built. |
notice | "cost" | "oops" | "earned" | null | The notice up over it, if any. |
PetCreatorLook
The pet the pet creator shows.
| Field | Type | |
|---|---|---|
defId | number | The pet type (_petDefId), which the adopt request carries. |
index | number | Its place in the list offered (_currIndex). |
color1 | number | The palette index each wheel is on. |
color2 | number |
PetCreatorTraits
The eyes and three traits of the pet shown.
| Field | Type | |
|---|---|---|
eye | PetCreatorOption | |
traits | [PetCreatorOption, PetCreatorOption, PetCreatorOption] |
PetCreatorOption
One thing to choose between, counted from 1 as the pet creator's windows are; 0 for none.
| Field | Type | |
|---|---|---|
chosen | number | |
count | number |
PetCreatorPrice
What the pet shown costs.
| Field | Type | |
|---|---|---|
cost | number | |
currency | PetCreatorCurrency | |
balance | number | What the player had as the pet was chosen (_gemCount). |
affordable | boolean | |
free | boolean | Won or redeemed (_isFromRedemption): nothing is paid. |
memberOnly | boolean | |
diamond | boolean | Bought with diamonds from the diamond shop (_specialIitemDef). |
PetCreatorCurrency
What the pet creator pays in.
type PetCreatorCurrency = 'gems' | 'tickets' | 'earth' | 'diamonds'PetCreatorName
The name the pet creator has made, and where each wheel is.
| Field | Type | |
|---|---|---|
name | string | |
first | string | null | |
second | string | null | |
firstIndex | number | |
secondIndex | number |
PetCreatorChoice
One of the pets the pet creator offers.
| Field | Type | |
|---|---|---|
index | number | |
defId | number | |
name | string | null | |
diamond | boolean | |
memberOnly | boolean |
PetCreatorWheel
Which of the pet creator's two colour wheels.
type PetCreatorWheel = 'color1' | 'color2'EditorColorGrid
One of the editors' colour grids or wheels (gui.ColorTable).
| Field | Type | |
|---|---|---|
current | number | The palette index chosen (ColorTable._currColor). |
indexes | number[] | The indexes the grid offers, in the order it draws them (_colorIndexes). |
PetCreatorTab
One of the pet creator's tabs.
type PetCreatorTab = 'colors' | 'traits' | 'eyes'PetCreatorStep
One of the pet creator's three screens.
type PetCreatorStep = 'choose' | 'customise' | 'name'PetCreatorAdopted
A pet the pet creator adopted, as the server made it (pc).
| Field | Type | |
|---|---|---|
invId | number | |
name | string | |
lBits | number | |
uBits | number | |
eBits | number | |
balance | number | What is left of the currency it cost, and which currency. |
currencyType | number |