Dens
phantom.aj.densWhere you are
Dens: visiting, rooms, items, privacy, guests.
Scripts and plugins
A script has all of it, as phantom.aj.dens, 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
| Member | What it does | Plugins |
|---|---|---|
buyRoom() | Buys a whole new den room from a den room shop, as its buy button does (requestBuy(false…), db). | game:act |
epicDens() | The epic dens the world map lists, by owner (requestDenHighest, dh). | game:act |
guests() | Who is in the player's own den with them now, read from the client's avatars; empty anywhere else. | game:read |
isChangePending() | Whether the client is between a den join or switch and the new room (_denChangePending). | game:read |
isOwn() | Whether the room on screen is the player's own den (RoomManagerWorld.isMyDen). | game:read |
join() | Joins someone's den by account name, as a buddy card's den button does (requestDenJoinFull), and resolves once the server has put the player in it. | game:act |
joinOwn() | Joins the player's own den, as the HUD's den button does. | game:act |
owner() | Whose den is on screen, by account name (RoomManagerWorld.denOwnerName); null elsewhere. | game:read |
privacyOf() | Who may come into someone's den (requestUserDenPrivacy): 0 nobody, 1 buddies, 2 everyone. | game:act |
recycleRooms() | Sells whole den rooms back, as the den switcher's remove does (requestRecycle(false…), dr). | game:act |
rooms() | The player's den rooms (requestDenRoomList, dl): each one's invIdx and den room def. | game:act |
setPhantom() | Turns the player into a phantom or back, as a den's phantom portal does (requestDenPhantom, dph); everyone in the room sees it. | game:act |
setPrivacy() | Sets who may come into the player's den, as the den editor's lock does: the client's own setting (userInfo.denPrivacySettings) so its lock button agrees, then the server (requestSetDenPrivacy). | game:act |
switchRoom() | Makes another of the player's den rooms their den, by the invIdx rooms() gives, as the den switcher does (DenSwitch.switchDens, dc). | game:act |
whenSettled() | Waits until the den on screen has settled: the client is no longer between a den join or a room switch and the new room being drawn (DenXtCommManager._denChangePending). | game:read |
onEntered() | Hears the player join any den, the player's own included. | game:read |
onEpicDens() | Hears the epic dens list arrive, whoever asked (dh). | game:read |
onGuestArrive() | Hears someone come into the player's own den, and each already there as the player comes home. | game:read |
onGuestLeave() | Hears a guest leave the player's own den while the player is there. | game:read |
onKicked() | Hears the player sent out of a den its owner locked (dpk). | game:read |
onOwnDen() | Hears the player come home to their own den (true), and leave it for anywhere else (false). | game:read |
onPhantom() | Hears anyone in the room turn into a phantom or back (dph); refusals are left out. | game:read |
onPrivacy() | Hears someone's den privacy answered, whoever asked (dp). | game:read |
onRoomChanged() | Hears a switch to another den room, whoever asked (dc). | game:read |
onRooms() | Hears the player's den rooms listed (dl): after rooms, and unasked after a room is bought. | game:read |
onVisit() | Hears someone come into or leave the player's own den, wherever the player is (drc): the server tells the owner even while out. | game:read |
dens.items: What is placed in the den on screen: phantom.aj.dens.items.
| Member | What it does | Plugins |
|---|---|---|
all() | Everything placed in the den on screen, in one message; none outside a den. | game:read |
at() | What is under a point of the room, by the client's own hit test (DenItemHolder.hitTest): the topmost item by layer, never the theme, as the player would pick it up. | game:read |
empty() | Empties the player's den, as the editor's clear does once the player says yes (requestEmptyDen, de). | game:act |
get() | One placed item by its refId and invIdx, or null. | game:read |
linkDoor() | Points one of the den's doors (specialType 1) at somebody's den, or nobody's with '', as the editor's link button does (DenItemHolder.onSelectUserToLink). | game:act |
move() | Moves something already in the player's den, drawn there as dragging it draws it (DenItemHolder.setItemMatrix), and saves the den. | game:act |
place() | Puts one of the player's den items into their den, as dragging it out of the editor's drawer does (spawnNewDenItem), and saves the den. | game:act |
placement() | How many things are placed in the den on screen, and how many the den editor allows (101, and 200 more for a member, as DenEditor works it out); null outside a den. | game:read |
remove() | Takes something out of the player's den, back to the drawer (DenItemHolder.removeItem), and saves the den. | game:act |
save() | Saves the player's den as it now stands, as the editor's save does, editor open or not. | game:act |
saveItems() | Saves the changes given straight to the server (requestDenStateChange), whatever the holder holds; what a change leaves out is read off the item on screen. | game:act |
onEdited() | Hears the client rebuild the den on screen (DenItemHolder.setItems): entering a den, a save, a place or a removal. | game:read |
onEmptied() | Hears a den emptied, whoever emptied it (de). | game:read |
onSaved() | Hears the server take a den save, whoever saved (dss): the invIdx of each item saved. | game:read |
onSaving() | Hears the client send a den save, before the server answers (ds, as the client sends it). | game:read |
onSpawned() | Hears each item the client puts into the den (spawnNewDenItem), as it is placed. | game:read |
onState() | Hears the server describe the den on screen (ds): entering a den, and the owner saving with the player inside. | game:read |
dens.editor: The client's own den editing: phantom.aj.dens.editor.
| Member | What it does | Plugins |
|---|---|---|
blocksWalking() | Whether something placed in the den stops an animal walking through a screen point (DenItemHolder.shouldStopMovement, which hit tests each moveToDisabled item). | game:read |
dragTo() | Moves the item being dragged to a screen point, as the mouse moving does (handleMouse(x, y, true)); its buttons follow it. | game:act |
editing() | What the editing is doing now: whether an item is being dragged, how many things are in the den against how many at the last save, and the item last picked up. | game:read |
holder() | The holder's own fields, in one message: its mode, the drag, the glow, the popups over it. | game:read |
lockItems() | Stops, or lets back, the mouse on the den's items, as the editor opening does (stopListenersOnPets, stopMouseOnNonMouseItems), so clicks land on what a plugin draws. | game:act |
openDoorLinkList() | Opens the buddy list beside the door being dragged, as its link button does (onLinkBtn). | game:act |
pickUp() | Picks up whatever is under a screen point, as the mouse pressing does (DenItemHolder.handleMouse(x, y, false)). | game:act |
press() | Presses one of the things placed in the den, as a click on it does (DenItemHolder.sendMouseEventToItem): a toy plays, a shop opens, a minigame starts, whatever room mode the den is in. | game:act |
removeDragged() | Takes the item being dragged out of the den, as its close button does (onCloseBtn): out on this screen at once, out of the player's den once it is saved. | game:act |
onEditing() | Hears the editing change: an item picked up or put down, a thing placed or taken out, a den going from saved to unsaved. | game:read |
onStep() | Hears each step the holder takes, by the client's own method name: an item placed (setItem) or let go (releaseItem), its art loaded, a button pressed, the mouse stopped… setBtnPos and updateCloseBtn are told on every frame of a drag. | game:read |
dens.editor.drawer: The den editor's drawer (gui.DenEditor): its tabs, its list, placing items, music, lock.
| Member | What it does | Plugins |
|---|---|---|
close() | Closes the drawer, as its close button does, closing its popups with it. | game:act |
closePanel() | Closes the music or the lock popup, as its close button does. | game:act |
current() | The den editor as it stands, in one message; null outside a den. | game:read |
isOpen() | Whether the den editor's drawer is open (isDenHudOpen). | game:read |
items() | The den items the open tab lists. | game:read |
music() | The songs the music popup lists; the one placed is the one playing. | game:act |
open() | Opens the drawer, as the HUD's customise button does, and resolves once it is open. | game:act |
openPanel() | Opens one of the den editor's popups as its button does: the den shop, the recycler, the den switcher, the music or the lock. | game:act |
page() | Scrolls the drawer a page left or right, as its arrows do; resolves with where it is. | game:act |
place() | Places a den item in the den from the drawer, as clicking its window does, and resolves with it once it is out. | game:act |
playMusic() | Plays one of the den's songs, as choosing it in the music popup does. | game:act |
remove() | Takes a den item back into the drawer, as clicking its window does. | game:act |
scroll() | Where the drawer's list is scrolled; null when it is not built. | game:read |
scrollTo() | Scrolls the drawer to show the item at index. | game:act |
search() | Filters the drawer by a search, as typing in its search bar does; empty text clears it. | game:act |
showCategory() | Shows one of the drawer's tabs, as pressing it does. | game:act |
tabs() | Every tab, how many it lists, whether it is offered and whether it is open. | game:read |
onBarShown() | Hears the editor's bar shown or hidden from outside (toggleEditorHud): a den preview, a game. | game:read |
onButton() | Hears the player's mouse on the den editor's own buttons; with hover, over and off too. | game:read |
onCategory() | Hears the open tab change. | game:read |
onDrawn() | Hears the drawer's windows drawn again (drawItemWindows): a tab, a search, a change of items. | game:read |
onItem() | Hears a den item placed from the drawer, or taken back into it. | game:read |
onOpenChange() | Hears the drawer open or close (toggleBottomHudVisibility). | game:read |
dens.inventory: The den items the player owns: phantom.aj.dens.inventory.
| Member | What it does | Plugins |
|---|---|---|
addDefinition() | Adds a den item def to the client's own, as its den item pack (1030) adds each as it loads: from the entry as the pack holds it, its name translated from nameStrId as it is made (put the words there first with phantom.aj.localization.addText). | game:act |
all() | Every den item the player owns, placed or in the drawer, in the client's order. | game:read |
buy() | Buys a den item, as a den shop's buy button does (requestBuy(true…), db). | game:act |
definition() | What one den item is, from the def pack (getDenItemDef), or null for none. | game:read |
definitions() | Every den item there is, out of the def pack (DenXtCommManager._denItemDefs), a page at a time. | game:read |
get() | One of the player's den items by invIdx, or null when they have none by it. | game:read |
limits() | The den editor's caps (ShopManager.maxDenItems…), a members' raise included; null before the client has them. | game:read |
recycle() | Sells den items back, as the recycle window does (requestRecycle(true…), dr). | game:act |
refresh() | Asks the server for the player's den items again (requestDenItems, di), and reads them. | game:act |
shopStands() | The player's own den shop stands, placed or packed away: a den item whose definition makes it a shop (specialType 5). | game:act |
onList() | Hears the player's den items listed by the server, whoever asked (di): each as the server wrote it, a mannequin's outfit read with the client's own defs. | game:read |
onPurchase() | Hears each den item or den room purchase answered, whoever bought (db), refusals too. | game:read |
onSale() | Hears den items or den rooms sold back, whoever sold them (dr). | game:read |
dens.eco: The den's eco system: phantom.aj.dens.eco.
| Member | What it does | Plugins |
|---|---|---|
consumers() | Each eco item in the den on screen and its state, read from the client's placed items (DenStateItem.ecoConsumerStateId): 0 off, 1 on, 2 on but offline for want of power. | game:read |
points() | The eco item popup, or null when it is not open. | game:read |
redeem() | Turns the den's unredeemed eco credits into the ecoCredits currency, as the eco score popup's redeem does (requestDenEcoCreditRedeem, dEr). | game:act |
refreshScore() | Asks the server for the den's eco score again, as the popup's own timer does. | game:act |
score() | The eco score popup, or null when it is not open. | game:read |
setConsumer() | Turns one of the den's eco items on or off, as its toggle in the eco points popup does (requestDenEcoConsumer, dEc). | game:act |
state() | The den's eco system as the server has it now (requestDenEcoCreditRefresh, dEf). | game:read |
switchItem() | Switches the eco item on or off, as its toggle does; one already so is left alone. | game:act |
takeGift() | Takes the eco gift, which the gift button offers only once it is lit. | game:act |
onConsumers() | Hears an eco item turned on or off, whoever did it (dEc). | game:read |
onRedeemed() | Hears eco credits redeemed, whoever asked (dEr); refusals are left out. | game:read |
onState() | Hears the den's eco system described, whoever asked (dEf). | game:read |
dens.switcher: The den switcher window: phantom.aj.dens.switcher.
| Member | What it does | Plugins |
|---|---|---|
closeShop() | Closes the den shop the switcher opened over itself (closeDenShop). | game:act |
current() | The switcher as it stands, or null when it is not open or its art is not in. | game:read |
pressSlot() | Presses a slot, as the player does. | game:act |
rebuild() | Draws the switcher's slots again from the client's own list (buildWindows). | game:act |
setMessage() | Shows a warning of your own in the switcher's own warning box, darkening the rest as the client does, or takes it down with null. | game:act |
setRecycling() | Turns recycling on or off, as its recycle button does, and confirms the switcher did. | game:act |
setShown() | Shows or hides the switcher's own art without closing it (showDenSwitcher). | game:act |
slots() | Every slot, with the den in it. | game:read |
onChange() | Hears what happens on the switcher: ready, a slot pressed, a switch, a recycle, a warning. | game:read |
Methods
buyRoom
buyRoom(defId: number, options: DenBuyOptions) => Promise<DenPurchase>Buys a whole new den room from a den room shop, as its buy button does (requestBuy(false…), db). Spends the player's currency and cannot be undone. Resolves with the balance after; throws REFUSED when the server will not sell it. The new room follows on onRooms.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options | DenBuyOptions |
Returns
Promise<DenPurchase>
Types
epicDens
epicDens(options?: ActOptions) => Promise<string[]>The epic dens the world map lists, by owner (requestDenHighest, dh).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<string[]>
Types
guests
guests() => Promise<DenGuest[]>Who is in the player's own den with them now, read from the client's avatars; empty anywhere else. arrivedAt is when this area heard each arrive, which it starts following from the first call (the client keeps no arrival times), so it is null for a guest already there before.
Returns
Promise<DenGuest[]>
Types
isChangePending
isChangePending() => Promise<boolean>Whether the client is between a den join or switch and the new room (_denChangePending).
Returns
Promise<boolean>
isOwn
isOwn() => Promise<boolean>Whether the room on screen is the player's own den (RoomManagerWorld.isMyDen).
Returns
Promise<boolean>
join
join(owner: string, options?: ActOptions) => Promise<DenJoin>Joins someone's den by account name, as a buddy card's den button does (requestDenJoinFull), and resolves once the server has put the player in it. Throws REFUSED with the server's reason (a locked den, a full one), and NOT_READY while the client is already changing room. Joining the den the player is in resolves at once.
Parameters
| Name | Type | |
|---|---|---|
owner | string | |
options optional | ActOptions |
Returns
Promise<DenJoin>
Types
joinOwn
joinOwn(options?: ActOptions) => Promise<DenJoin>Joins the player's own den, as the HUD's den button does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenJoin>
Types
owner
owner() => Promise<string | null>Whose den is on screen, by account name (RoomManagerWorld.denOwnerName); null elsewhere.
Returns
Promise<string \| null>
privacyOf
privacyOf(userName: string, options?: ActOptions) => Promise<DenPrivacy>Who may come into someone's den (requestUserDenPrivacy): 0 nobody, 1 buddies, 2 everyone.
Parameters
| Name | Type | |
|---|---|---|
userName | string | |
options optional | ActOptions |
Returns
Promise<DenPrivacy>
Types
recycleRooms
recycleRooms(invIdxs: readonly number[], options?: ActOptions) => Promise<number[]>Sells whole den rooms back, as the den switcher's remove does (requestRecycle(false…), dr). Cannot be undone. Resolves with the invIdxes sold; throws REFUSED when none were (the den in use is never sold).
Parameters
| Name | Type | |
|---|---|---|
invIdxs | readonly number[] | |
options optional | ActOptions |
Returns
Promise<number[]>
Types
rooms
rooms(options?: ActOptions) => Promise<DenRoom[]>The player's den rooms (requestDenRoomList, dl): each one's invIdx and den room def.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenRoom[]>
Types
setPhantom
setPhantom(phantom: boolean, options?: ActOptions) => Promise<DenPhantomChange>Turns the player into a phantom or back, as a den's phantom portal does (requestDenPhantom, dph); everyone in the room sees it. Throws REFUSED when the server will not (it allows it only where a portal is).
Parameters
| Name | Type | |
|---|---|---|
phantom | boolean | |
options optional | ActOptions |
Returns
Promise<DenPhantomChange>
Types
setPrivacy
setPrivacy(privacy: DenPrivacy, options?: ActOptions) => Promise<DenPrivacy>Sets who may come into the player's den, as the den editor's lock does: the client's own setting (userInfo.denPrivacySettings) so its lock button agrees, then the server (requestSetDenPrivacy). The server sends no answer to it, so this resolves once the client holds the new setting. Locking the den sends any visitors out.
Parameters
| Name | Type | |
|---|---|---|
privacy | DenPrivacy | |
options optional | ActOptions |
Returns
Promise<DenPrivacy>
Types
switchRoom
switchRoom(invIdx: number, options?: ActOptions) => Promise<DenRoomChange>Makes another of the player's den rooms their den, by the invIdx rooms() gives, as the den switcher does (DenSwitch.switchDens, dc). Resolves with the server's switch once it has made it; the new room loads after (whenSettled). Throws REFUSED for a room the player does not own.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<DenRoomChange>
Types
whenSettled
whenSettled(options?: ActOptions) => Promise<void>Waits until the den on screen has settled: the client is no longer between a den join or a room switch and the new room being drawn (DenXtCommManager._denChangePending). Resolves at once when nothing is pending; throws TIMEOUT (twenty seconds by default) when it never does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
Events
onEntered
onEntered(listener: (den: DenJoin) => void) => () => voidHears the player join any den, the player's own included.
Parameters
| Name | Type | |
|---|---|---|
listener | (den: DenJoin) => void |
Returns
() => void. Call it to stop listening.
Types
onEpicDens
onEpicDens(listener: (owners: string[]) => void) => () => voidHears the epic dens list arrive, whoever asked (dh).
Parameters
| Name | Type | |
|---|---|---|
listener | (owners: string[]) => void |
Returns
() => void. Call it to stop listening.
onGuestArrive
onGuestArrive(listener: (guest: DenGuestArrival) => void) => () => voidHears someone come into the player's own den, and each already there as the player comes home.
Parameters
| Name | Type | |
|---|---|---|
listener | (guest: DenGuestArrival) => void |
Returns
() => void. Call it to stop listening.
Types
onGuestLeave
onGuestLeave(listener: (guest: DenGuestLeft) => void) => () => voidHears a guest leave the player's own den while the player is there.
Parameters
| Name | Type | |
|---|---|---|
listener | (guest: DenGuestLeft) => void |
Returns
() => void. Call it to stop listening.
Types
onKicked
onKicked(listener: () => void) => () => voidHears the player sent out of a den its owner locked (dpk).
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onOwnDen
onOwnDen(listener: (inside: boolean) => void) => () => voidHears the player come home to their own den (true), and leave it for anywhere else (false).
Parameters
| Name | Type | |
|---|---|---|
listener | (inside: boolean) => void |
Returns
() => void. Call it to stop listening.
onPhantom
onPhantom(listener: (change: DenPhantomChange) => void) => () => voidHears anyone in the room turn into a phantom or back (dph); refusals are left out.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: DenPhantomChange) => void |
Returns
() => void. Call it to stop listening.
Types
onPrivacy
onPrivacy(listener: (answer: { userName: string; privacy: DenPrivacy; }) => void) => () => voidHears someone's den privacy answered, whoever asked (dp).
Parameters
| Name | Type | |
|---|---|---|
listener | (answer: { userName: string; privacy: DenPrivacy; }) => void |
Returns
() => void. Call it to stop listening.
Types
onRoomChanged
onRoomChanged(listener: (change: DenRoomChange) => void) => () => voidHears a switch to another den room, whoever asked (dc).
Parameters
| Name | Type | |
|---|---|---|
listener | (change: DenRoomChange) => void |
Returns
() => void. Call it to stop listening.
Types
onRooms
onRooms(listener: (rooms: DenRoom[]) => void) => () => voidHears the player's den rooms listed (dl): after rooms, and unasked after a room is bought.
Parameters
| Name | Type | |
|---|---|---|
listener | (rooms: DenRoom[]) => void |
Returns
() => void. Call it to stop listening.
Types
onVisit
onVisit(listener: (visit: DenVisit) => void) => () => voidHears someone come into or leave the player's own den, wherever the player is (drc): the server tells the owner even while out. The player's own comings and goings are left out.
Parameters
| Name | Type | |
|---|---|---|
listener | (visit: DenVisit) => void |
Returns
() => void. Call it to stop listening.
Types
dens.items
What is placed in the den on screen: phantom.aj.dens.items. Read from the client's own item holder (room.DenItemHolder._currItems), whoever's den it is; placing, moving and taking things out change the player's own den and are saved as the den editor saves, confirmed by the server.
all
all() => Promise<DenPlacedItem[]>Everything placed in the den on screen, in one message; none outside a den.
Returns
Promise<DenPlacedItem[]>
Types
at
at(point: { x: number; y: number; }) => Promise<DenPlacedItem | null>What is under a point of the room, by the client's own hit test (DenItemHolder.hitTest): the topmost item by layer, never the theme, as the player would pick it up. Room coordinates; null where nothing is, and outside a den.
Parameters
| Name | Type | |
|---|---|---|
point | { x: number; y: number; } |
Returns
Promise<DenPlacedItem \| null>
Types
empty
empty(options?: ActOptions) => Promise<void>Empties the player's den, as the editor's clear does once the player says yes (requestEmptyDen, de). Nothing is lost: every item goes back to the drawer.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
get
get(ref: DenItemRef) => Promise<DenPlacedItem | null>One placed item by its refId and invIdx, or null.
Parameters
| Name | Type | |
|---|---|---|
ref | DenItemRef |
Returns
Promise<DenPlacedItem \| null>
Types
linkDoor
linkDoor(ref: DenItemRef, userName: string, options?: ActOptions) => Promise<DenPlacedItem>Points one of the den's doors (specialType 1) at somebody's den, or nobody's with '', as the editor's link button does (DenItemHolder.onSelectUserToLink). In the player's own den it is saved for everybody; in anyone else's it changes this screen only, until the den loads again. Resolves with the door; throws REFUSED for an item that is not a door.
Parameters
| Name | Type | |
|---|---|---|
ref | DenItemRef | |
userName | string | |
options optional | ActOptions |
Returns
Promise<DenPlacedItem>
Types
move
move(ref: DenItemRef, placement: DenItemPlacement, options?: ActOptions) => Promise<DenPlacedItem>Moves something already in the player's den, drawn there as dragging it draws it (DenItemHolder.setItemMatrix), and saves the den. Resolves with the item where it now is.
Parameters
| Name | Type | |
|---|---|---|
ref | DenItemRef | |
placement | DenItemPlacement | |
options optional | ActOptions |
Returns
Promise<DenPlacedItem>
Types
place
place(invIdx: number, placement?: DenItemPlacement, options?: ActOptions) => Promise<DenPlacedItem>Puts one of the player's den items into their den, as dragging it out of the editor's drawer does (spawnNewDenItem), and saves the den. The item is built from the client's own copy, so its layer, looks and sounds are the client's. Resolves with the item placed; throws REFUSED for an invIdx the player has no den item by, NOT_READY outside their own den.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
placement optional | DenItemPlacement | |
options optional | ActOptions |
Returns
Promise<DenPlacedItem>
Types
placement
placement() => Promise<DenPlacement | null>How many things are placed in the den on screen, and how many the den editor allows (101, and 200 more for a member, as DenEditor works it out); null outside a den.
Returns
Promise<DenPlacement \| null>
Types
remove
remove(ref: DenItemRef, options?: ActOptions) => Promise<void>Takes something out of the player's den, back to the drawer (DenItemHolder.removeItem), and saves the den. Throws REFUSED for an item not in the den.
Parameters
| Name | Type | |
|---|---|---|
ref | DenItemRef | |
options optional | ActOptions |
Returns
Promise<void>
Types
save
save(options?: ActOptions) => Promise<number[]>Saves the player's den as it now stands, as the editor's save does, editor open or not. Resolves with the invIdxes the server saved, none when nothing had changed.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<number[]>
Types
saveItems
saveItems(changes: readonly DenItemSave[], options?: ActOptions) => Promise<number[]>Saves the changes given straight to the server (requestDenStateChange), whatever the holder holds; what a change leaves out is read off the item on screen. The den on screen is not redrawn: onState hears the server's own description.
Parameters
| Name | Type | |
|---|---|---|
changes | readonly DenItemSave[] | |
options optional | ActOptions |
Returns
Promise<number[]>
Types
onEdited
onEdited(listener: (items: DenPlacedItem[]) => void) => () => voidHears the client rebuild the den on screen (DenItemHolder.setItems): entering a den, a save, a place or a removal. The listener is handed all(), read afresh.
Parameters
| Name | Type | |
|---|---|---|
listener | (items: DenPlacedItem[]) => void |
Returns
() => void. Call it to stop listening.
Types
onEmptied
onEmptied(listener: () => void) => () => voidHears a den emptied, whoever emptied it (de).
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onSaved
onSaved(listener: (invIdxs: number[]) => void) => () => voidHears the server take a den save, whoever saved (dss): the invIdx of each item saved.
Parameters
| Name | Type | |
|---|---|---|
listener | (invIdxs: number[]) => void |
Returns
() => void. Call it to stop listening.
onSaving
onSaving(listener: (changes: DenStateChange[]) => void) => () => voidHears the client send a den save, before the server answers (ds, as the client sends it).
Parameters
| Name | Type | |
|---|---|---|
listener | (changes: DenStateChange[]) => void |
Returns
() => void. Call it to stop listening.
Types
onSpawned
onSpawned(listener: (item: DenPlacedItem) => void) => () => voidHears each item the client puts into the den (spawnNewDenItem), as it is placed.
Parameters
| Name | Type | |
|---|---|---|
listener | (item: DenPlacedItem) => void |
Returns
() => void. Call it to stop listening.
Types
onState
onState(listener: (state: DenServerState) => void) => () => voidHears the server describe the den on screen (ds): entering a den, and the owner saving with the player inside. A mannequin's outfit is read with the client's own defs.
Parameters
| Name | Type | |
|---|---|---|
listener | (state: DenServerState) => void |
Returns
() => void. Call it to stop listening.
Types
DenServerState · DenStateEntry · DenMannequinOutfit · DenStatePet
dens.editor
The client's own den editing: phantom.aj.dens.editor. The den item holder (room.DenItemHolder) is where an edit of the den on screen lives, and none of it is sent until the den is saved (dens.items.save); joining the room again puts the den back as the server has it. Points are screen points, as the client gets them from the mouse (phantom.aj.room.toScreen converts a room position).
blocksWalking
blocksWalking(point: Point) => Promise<boolean>Whether something placed in the den stops an animal walking through a screen point (DenItemHolder.shouldStopMovement, which hit tests each moveToDisabled item). False outside a den.
Parameters
| Name | Type | |
|---|---|---|
point | Point |
Returns
Promise<boolean>
Types
dragTo
dragTo(point: Point, options?: ActOptions) => Promise<DenEditingState>Moves the item being dragged to a screen point, as the mouse moving does (handleMouse(x, y, true)); its buttons follow it. Throws NOT_READY when nothing is held.
Parameters
| Name | Type | |
|---|---|---|
point | Point | |
options optional | ActOptions |
Returns
Promise<DenEditingState>
Types
editing
editing() => Promise<DenEditingState>What the editing is doing now: whether an item is being dragged, how many things are in the den against how many at the last save, and the item last picked up. Outside a den it is all 0, false and null.
Returns
Promise<DenEditingState>
Types
holder
holder() => Promise<DenHolderState>The holder's own fields, in one message: its mode, the drag, the glow, the popups over it.
Returns
Promise<DenHolderState>
Types
lockItems
lockItems(locked: boolean, options?: ActOptions) => Promise<void>Stops, or lets back, the mouse on the den's items, as the editor opening does (stopListenersOnPets, stopMouseOnNonMouseItems), so clicks land on what a plugin draws. The client puts it back the next time it sets the room's mode.
Parameters
| Name | Type | |
|---|---|---|
locked | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
openDoorLinkList
openDoorLinkList(options?: ActOptions) => Promise<void>Opens the buddy list beside the door being dragged, as its link button does (onLinkBtn). dens.items.linkDoor links one directly. Throws REFUSED when the item held is not a door.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
pickUp
pickUp(point: Point, options?: ActOptions) => Promise<DenEditingState>Picks up whatever is under a screen point, as the mouse pressing does (DenItemHolder.handleMouse(x, y, false)). Resolves with the editing, the item picked up in selected; throws REFUSED when nothing is there to pick up.
Parameters
| Name | Type | |
|---|---|---|
point | Point | |
options optional | ActOptions |
Returns
Promise<DenEditingState>
Types
press
press(ref: DenItemRef, options?: ActOptions) => Promise<void>Presses one of the things placed in the den, as a click on it does (DenItemHolder.sendMouseEventToItem): a toy plays, a shop opens, a minigame starts, whatever room mode the den is in. Throws REFUSED for an item not in the den or not drawn yet.
Parameters
| Name | Type | |
|---|---|---|
ref | DenItemRef | |
options optional | ActOptions |
Returns
Promise<void>
Types
removeDragged
removeDragged(options?: ActOptions) => Promise<void>Takes the item being dragged out of the den, as its close button does (onCloseBtn): out on this screen at once, out of the player's den once it is saved.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
onEditing
onEditing(listener: (editing: DenEditingState) => void) => () => voidHears the editing change: an item picked up or put down, a thing placed or taken out, a den going from saved to unsaved. Watched in the game (isDragging, numberOfInUseItems, numberOfInitItems), so a den sitting still costs nothing; told with editing() read afresh.
Parameters
| Name | Type | |
|---|---|---|
listener | (editing: DenEditingState) => void |
Returns
() => void. Call it to stop listening.
Types
onStep
onStep(listener: (step: "setItem" | "releaseItem" | "release" | "clearDen" | "itemLoaded" | "onCloseBtn" | "onFlipBtn" | "onLinkBtn" | "onItemDown" | "onPortalItemDown" | "sendMouseEvent" | "sendMouseEventToItem" | "addListenersToItem" | "addPortalListenersToItem" | "removeListenersFromItem" | "removePortalListenersFromItem" | "removeAccessoryAndRebuildMannequin" | "onMannequinAvEditorClose" | "onEcoPopupClose" | "onEcoPointsPopupClose" | "updateConsumers" | "stopListenersOnPets" | "stopMouseOnNonMouseItems" | "setRoomMode" | "setThemePosition" | "updateCloseBtn" | "setBtnPos") => void) => () => voidHears each step the holder takes, by the client's own method name: an item placed (setItem) or let go (releaseItem), its art loaded, a button pressed, the mouse stopped… setBtnPos and updateCloseBtn are told on every frame of a drag.
Parameters
| Name | Type | |
|---|---|---|
listener | (step: "setItem" | "releaseItem" | "release" | "clearDen" | "itemLoaded" | "onCloseBtn" | "onFlipBtn" | "onLinkBtn" | "onItemDown" | "onPortalItemDown" | "sendMouseEvent" | "sendMouseEventToItem" | "addListenersToItem" | "addPortalListenersToItem" | "removeListenersFromItem" | "removePortalListenersFromItem" | "removeAccessoryAndRebuildMannequin" | "onMannequinAvEditorClose" | "onEcoPopupClose" | "onEcoPointsPopupClose" | "updateConsumers" | "stopListenersOnPets" | "stopMouseOnNonMouseItems" | "setRoomMode" | "setThemePosition" | "updateCloseBtn" | "setBtnPos") => void |
Returns
() => void. Call it to stop listening.
dens.editor.drawer
The den editor's drawer (gui.DenEditor): its tabs, its list, placing items, music, lock.
close
close(options?: ActOptions) => Promise<DenEditorState>Closes the drawer, as its close button does, closing its popups with it.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenEditorState>
Types
closePanel
closePanel(panel: "music" | "lock", options?: ActOptions) => Promise<void>Closes the music or the lock popup, as its close button does.
Parameters
| Name | Type | |
|---|---|---|
panel | "music" | "lock" | |
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<DenEditorState | null>The den editor as it stands, in one message; null outside a den.
Returns
Promise<DenEditorState \| null>
Types
isOpen
isOpen() => Promise<boolean>Whether the den editor's drawer is open (isDenHudOpen). False outside a den.
Returns
Promise<boolean>
items
items(options?: EditorListOptions) => Promise<DenEditorItem[]>The den items the open tab lists.
Parameters
| Name | Type | |
|---|---|---|
options optional | EditorListOptions |
Returns
Promise<DenEditorItem[]>
Types
music
music(options?: EditorListOptions) => Promise<DenEditorItem[]>The songs the music popup lists; the one placed is the one playing.
Parameters
| Name | Type | |
|---|---|---|
options optional | EditorListOptions |
Returns
Promise<DenEditorItem[]>
Types
open
open(options?: ActOptions) => Promise<DenEditorState>Opens the drawer, as the HUD's customise button does, and resolves once it is open.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenEditorState>
Types
openPanel
openPanel(panel: DenEditorPanel, options?: ActOptions) => Promise<void>Opens one of the den editor's popups as its button does: the den shop, the recycler, the den switcher, the music or the lock. The shop, the recycler and the switcher save the den's items first, as the client does. Resolves once it is up.
Parameters
| Name | Type | |
|---|---|---|
panel | DenEditorPanel | |
options optional | ActOptions |
Returns
Promise<void>
Types
page
page(direction: "left" | "right", options?: ActOptions) => Promise<EditorScroll>Scrolls the drawer a page left or right, as its arrows do; resolves with where it is.
Parameters
| Name | Type | |
|---|---|---|
direction | "left" | "right" | |
options optional | ActOptions |
Returns
Promise<EditorScroll>
Types
place
place(invIdx: number, options?: ActOptions) => Promise<DenEditorItem>Places a den item in the den from the drawer, as clicking its window does, and resolves with it once it is out. The den is saved with phantom.aj.dens.items.save. Throws REFUSED for one not listed, one already out, or one the client will not place (the pet walking with the player, the den full).
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<DenEditorItem>
Types
playMusic
playMusic(invIdx: number, options?: ActOptions) => Promise<DenEditorItem>Plays one of the den's songs, as choosing it in the music popup does.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<DenEditorItem>
Types
remove
remove(invIdx: number, options?: ActOptions) => Promise<DenEditorItem>Takes a den item back into the drawer, as clicking its window does.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<DenEditorItem>
Types
scroll
scroll() => Promise<EditorScroll | null>Where the drawer's list is scrolled; null when it is not built.
Returns
Promise<EditorScroll \| null>
Types
scrollTo
scrollTo(index: number, options?: ActOptions) => Promise<EditorScroll>Scrolls the drawer 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 drawer by a search, as typing in its search bar does; empty text clears it.
Parameters
| Name | Type | |
|---|---|---|
text | string | |
options optional | ActOptions |
Returns
Promise<void>
Types
showCategory
showCategory(category: DenEditorCategory, options?: ActOptions) => Promise<void>Shows one of the drawer's tabs, as pressing it does. Throws REFUSED for an empty one.
Parameters
| Name | Type | |
|---|---|---|
category | DenEditorCategory | |
options optional | ActOptions |
Returns
Promise<void>
Types
tabs
tabs() => Promise<DenEditorTab[]>Every tab, how many it lists, whether it is offered and whether it is open.
Returns
Promise<DenEditorTab[]>
Types
onBarShown
onBarShown(listener: (shown: boolean) => void) => () => voidHears the editor's bar shown or hidden from outside (toggleEditorHud): a den preview, a game.
Parameters
| Name | Type | |
|---|---|---|
listener | (shown: boolean) => void |
Returns
() => void. Call it to stop listening.
onButton
onButton(listener: (event: EditorButtonEvent<DenEditorButton>) => void, options?: EditorButtonOptions) => () => voidHears the player's mouse on the den editor's own buttons; with hover, over and off too.
Parameters
| Name | Type | |
|---|---|---|
listener | (event: EditorButtonEvent<DenEditorButton>) => void | |
options optional | EditorButtonOptions |
Returns
() => void. Call it to stop listening.
Types
EditorButtonEvent · EditorMouseAction · DenEditorButton · EditorButtonOptions
onCategory
onCategory(listener: (category: DenEditorCategory) => void) => () => voidHears the open tab change.
Parameters
| Name | Type | |
|---|---|---|
listener | (category: DenEditorCategory) => void |
Returns
() => void. Call it to stop listening.
Types
onDrawn
onDrawn(listener: () => void) => () => voidHears the drawer's windows drawn again (drawItemWindows): a tab, a search, a change of items.
Parameters
| Name | Type | |
|---|---|---|
listener | () => void |
Returns
() => void. Call it to stop listening.
onItem
onItem(listener: (change: DenEditorItemChange) => void) => () => voidHears a den item placed from the drawer, or taken back into it.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: DenEditorItemChange) => void |
Returns
() => void. Call it to stop listening.
Types
onOpenChange
onOpenChange(listener: (open: boolean) => void) => () => voidHears the drawer open or close (toggleBottomHudVisibility).
Parameters
| Name | Type | |
|---|---|---|
listener | (open: boolean) => void |
Returns
() => void. Call it to stop listening.
dens.inventory
The den items the player owns: phantom.aj.dens.inventory. The editor's drawer as the client holds it (userInfo.playerUserInfo.denItemsFull), the def pack behind every den item, and buying and selling them, each confirmed by the server's answer.
addDefinition
addDefinition(entry: DenItemDefEntry, options?: AddDefinitionOptions) => Promise<DenItemDefinition>Adds a den item def to the client's own, as its den item pack (1030) adds each as it loads: from the entry as the pack holds it, its name translated from nameStrId as it is made (put the words there first with phantom.aj.localization.addText). For a den item the pack the client loaded did not have. Resolves with the def as the client then holds it; throws NOT_READY before the pack has loaded, and REFUSED for an id the client has a def by already (unless replace).
Parameters
| Name | Type | |
|---|---|---|
entry | DenItemDefEntry | |
options optional | AddDefinitionOptions |
Returns
Promise<DenItemDefinition>
Types
DenItemDefEntry · DefPackValue · AddDefinitionOptions · DenItemDefinition
Example
await phantom.aj.localization.addText(9_060_001, 'Star Lamp');
await phantom.aj.dens.inventory.addDefinition({ id: '60001', nameStrId: '9060001', sortCat: '0' });all
all(options?: ActOptions) => Promise<DenInventoryItem[]>Every den item the player owns, placed or in the drawer, in the client's order. The client fills the list as the player enters a den; when it has none yet it is asked for once (di). Pets are not here: a pet in the den comes from the pet list (phantom.aj.player.pets).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenInventoryItem[]>
Types
buy
buy(defId: number, options: ActOptions & { shopId: number; diamond?: boolean | undefined; } & { version?: number | undefined; }) => Promise<DenPurchase>Buys a den item, as a den shop's buy button does (requestBuy(true…), db). Spends the player's currency and cannot be undone. Resolves with the new copy's invIdx and the balance; throws REFUSED when the server will not sell it.
Parameters
| Name | Type | |
|---|---|---|
defId | number | |
options | ActOptions & { shopId: number; diamond?: boolean | undefined; } & { version?: number | undefined; } |
Returns
Promise<DenPurchase>
Types
definition
definition(defId: number) => Promise<DenItemDefinition | null>What one den item is, from the def pack (getDenItemDef), or null for none.
Parameters
| Name | Type | |
|---|---|---|
defId | number |
Returns
Promise<DenItemDefinition \| null>
Types
definitions
definitions() => Promise<DenItemDefinition[]>Every den item there is, out of the def pack (DenXtCommManager._denItemDefs), a page at a time. Thousands of items; empty before the pack arrives.
Returns
Promise<DenItemDefinition[]>
Types
get
get(invIdx: number, options?: ActOptions) => Promise<DenInventoryItem | null>One of the player's den items by invIdx, or null when they have none by it.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
options optional | ActOptions |
Returns
Promise<DenInventoryItem \| null>
Types
limits
limits() => Promise<DenLimits | null>The den editor's caps (ShopManager.maxDenItems…), a members' raise included; null before the client has them.
Returns
Promise<DenLimits \| null>
Types
recycle
recycle(invIdxs: readonly number[], options?: ActOptions) => Promise<DenSale>Sells den items back, as the recycle window does (requestRecycle(true…), dr). Cannot be undone. The server may keep some (placed, or in the den shop): resolves with what it sold and the gems after; throws REFUSED when it sold none.
Parameters
| Name | Type | |
|---|---|---|
invIdxs | readonly number[] | |
options optional | ActOptions |
Returns
Promise<DenSale>
Types
refresh
refresh(options?: ActOptions) => Promise<DenInventoryItem[]>Asks the server for the player's den items again (requestDenItems, di), and reads them.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<DenInventoryItem[]>
Types
shopStands
shopStands(options?: ActOptions) => Promise<OwnedDenShop[]>The player's own den shop stands, placed or packed away: a den item whose definition makes it a shop (specialType 5). storeInvId is what phantom.aj.denShop takes, wherever the player is.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<OwnedDenShop[]>
Types
onList
onList(listener: (items: DenOwnedItems) => void) => () => voidHears the player's den items listed by the server, whoever asked (di): each as the server wrote it, a mannequin's outfit read with the client's own defs. A list that cannot be read is logged, not told.
Parameters
| Name | Type | |
|---|---|---|
listener | (items: DenOwnedItems) => void |
Returns
() => void. Call it to stop listening.
Types
onPurchase
onPurchase(listener: (purchase: DenPurchaseHeard) => void) => () => voidHears each den item or den room purchase answered, whoever bought (db), refusals too.
Parameters
| Name | Type | |
|---|---|---|
listener | (purchase: DenPurchaseHeard) => void |
Returns
() => void. Call it to stop listening.
Types
onSale
onSale(listener: (sale: DenSale) => void) => () => voidHears den items or den rooms sold back, whoever sold them (dr).
Parameters
| Name | Type | |
|---|---|---|
listener | (sale: DenSale) => void |
Returns
() => void. Call it to stop listening.
Types
dens.eco
The den's eco system: phantom.aj.dens.eco. Wind turbines and solar panels generating, eco items drawing on them, and eco credits to redeem, for the den on screen; and its popups, an item's power (points) and the den's eco score (score).
consumers
consumers() => Promise<DenEcoConsumer[]>Each eco item in the den on screen and its state, read from the client's placed items (DenStateItem.ecoConsumerStateId): 0 off, 1 on, 2 on but offline for want of power.
Returns
Promise<DenEcoConsumer[]>
Types
points
points() => Promise<EcoPoints | null>The eco item popup, or null when it is not open.
Returns
Promise<EcoPoints \| null>
Types
redeem
redeem(options?: ActOptions) => Promise<{ secondsUntilNextEcoCredit: number | null; }>Turns the den's unredeemed eco credits into the ecoCredits currency, as the eco score popup's redeem does (requestDenEcoCreditRedeem, dEr). Resolves with the seconds until the next credit (null when the server left it out); throws REFUSED when the server redeems nothing.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<{ secondsUntilNextEcoCredit: number \| null; }>
Types
refreshScore
refreshScore(options?: ActOptions) => Promise<void>Asks the server for the den's eco score again, as the popup's own timer does.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
score
score() => Promise<EcoScore | null>The eco score popup, or null when it is not open.
Returns
Promise<EcoScore \| null>
Types
setConsumer
setConsumer(invIdx: number, online: boolean, options?: ActOptions) => Promise<DenEcoConsumers>Turns one of the den's eco items on or off, as its toggle in the eco points popup does (requestDenEcoConsumer, dEc). Resolves with the den's eco items as the server now has them; throws REFUSED when the server names the item in the state it was asked out of.
Parameters
| Name | Type | |
|---|---|---|
invIdx | number | |
online | boolean | |
options optional | ActOptions |
Returns
Promise<DenEcoConsumers>
Types
state
state(options?: ActOptions) => Promise<EcoState>The den's eco system as the server has it now (requestDenEcoCreditRefresh, dEf).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<EcoState>
Types
switchItem
switchItem(on: boolean, options?: ActOptions) => Promise<EcoPoints>Switches the eco item on or off, as its toggle does; one already so is left alone.
Parameters
| Name | Type | |
|---|---|---|
on | boolean | |
options optional | ActOptions |
Returns
Promise<EcoPoints>
Types
takeGift
takeGift(options?: ActOptions) => Promise<void>Takes the eco gift, which the gift button offers only once it is lit.
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
onConsumers
onConsumers(listener: (consumers: DenEcoConsumers) => void) => () => voidHears an eco item turned on or off, whoever did it (dEc).
Parameters
| Name | Type | |
|---|---|---|
listener | (consumers: DenEcoConsumers) => void |
Returns
() => void. Call it to stop listening.
Types
onRedeemed
onRedeemed(listener: (redeemed: { secondsUntilNextEcoCredit: number | null; }) => void) => () => voidHears eco credits redeemed, whoever asked (dEr); refusals are left out.
Parameters
| Name | Type | |
|---|---|---|
listener | (redeemed: { secondsUntilNextEcoCredit: number | null; }) => void |
Returns
() => void. Call it to stop listening.
onState
onState(listener: (state: EcoState) => void) => () => voidHears the den's eco system described, whoever asked (dEf).
Parameters
| Name | Type | |
|---|---|---|
listener | (state: EcoState) => void |
Returns
() => void. Call it to stop listening.
Types
dens.switcher
The den switcher window: phantom.aj.dens.switcher.
closeShop
closeShop(options?: ActOptions) => Promise<void>Closes the den shop the switcher opened over itself (closeDenShop).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
current
current() => Promise<DenSwitcherView | null>The switcher as it stands, or null when it is not open or its art is not in.
Returns
Promise<DenSwitcherView \| null>
Types
pressSlot
pressSlot(index: number, options?: ActOptions) => Promise<void>Presses a slot, as the player does.
Parameters
| Name | Type | |
|---|---|---|
index | number | |
options optional | ActOptions |
Returns
Promise<void>
Types
rebuild
rebuild(options?: ActOptions) => Promise<void>Draws the switcher's slots again from the client's own list (buildWindows).
Parameters
| Name | Type | |
|---|---|---|
options optional | ActOptions |
Returns
Promise<void>
Types
setMessage
setMessage(message: string | null, options?: ActOptions) => Promise<void>Shows a warning of your own in the switcher's own warning box, darkening the rest as the client does, or takes it down with null. Only this screen changes.
Parameters
| Name | Type | |
|---|---|---|
message | string | null | |
options optional | ActOptions |
Returns
Promise<void>
Types
setRecycling
setRecycling(on: boolean, options?: ActOptions) => Promise<void>Turns recycling on or off, as its recycle button does, and confirms the switcher did.
Parameters
| Name | Type | |
|---|---|---|
on | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
setShown
setShown(shown: boolean, options?: ActOptions) => Promise<void>Shows or hides the switcher's own art without closing it (showDenSwitcher).
Parameters
| Name | Type | |
|---|---|---|
shown | boolean | |
options optional | ActOptions |
Returns
Promise<void>
Types
slots
slots() => Promise<DenSlot[]>Every slot, with the den in it.
Returns
Promise<DenSlot[]>
Types
onChange
onChange(listener: (change: SwitcherChange) => void) => () => voidHears what happens on the switcher: ready, a slot pressed, a switch, a recycle, a warning.
Parameters
| Name | Type | |
|---|---|---|
listener | (change: SwitcherChange) => 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.
DenGuest
Someone in the player's own den with them.
| Field | Type | |
|---|---|---|
userId | number | Their id in the room. |
userName | string | |
avatarName | string | The name over their animal. |
uuid | string | null | |
arrivedAt | number | null | When they arrived, in epoch milliseconds, as this area heard it; null for somebody who was already there before the area heard anything (the client keeps no arrival times). |
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 |
DenJoin
A den joined: whose, and the room the server put the player in.
| Field | Type | |
|---|---|---|
owner | string | The owner, by account name, as the room is named (den<owner>). |
roomName | string | The room's own name, den and the owner. |
own | boolean | Whether it is the player's own den. |
DenPrivacy
Who may come into a den, as UserInfoCache.denPrivacySettings and the den editor's radio buttons hold it. BuddyCard.onDenPrivacyResponse reads the same numbers for someone else's den.
DenPrivacyDenRoom
One of the player's den rooms: its inventory index and its den room def.
| Field | Type | |
|---|---|---|
invIdx | number | The den room's place in the player's inventory, which den.change-request names. |
defId | number | The den room's def id. |
DenRoomChange
A switch to another of the player's den rooms, as the server reported it (dc).
| Field | Type | |
|---|---|---|
denRoomDefId | number | |
perUserAvId | number | null | Which of the player's avatars is out, or null when the server did not say. |
activePetInvId | number | null | The player's pet out, or null when the server did not say. |
DenBuyOptions
What a den room or den item is bought with.
type DenBuyOptions = ActOptions & {
/** The shop it is bought from, as the shop's list names it. */
shopId: number;
/** Pay in diamonds. */
diamond?: boolean;
}DenPurchase
What the server said about a den item or den room bought (db).
| Field | Type | |
|---|---|---|
balance | string | null | The balance afterwards, exactly as the server wrote it: a number for one currency, or the combined form (4x10,6x5); null when it sent none. |
currencyType | number | Which currency balance is (CURRENCY). |
invIdx | number | null | Which of the player's copies it became; null for a den room, which rooms() lists. |
DenPhantomChange
Someone in the room turning into a phantom or back (dph).
| Field | Type | |
|---|---|---|
userId | number | |
phantom | boolean |
DenVisit
Someone coming into or leaving the player's own den, heard wherever the player is (drc).
| Field | Type | |
|---|---|---|
userName | string | |
entering | boolean | They came in; false when they went out. |
count | number | How many are in the den now, as the server counts them. |
at | number | When it was heard. |
DenGuestArrival
A guest arriving in the player's own den, or already there when the player came home.
type DenGuestArrival = DenGuest & {
arrivedAt: number;
/** They were in the den before the player came home, rather than arriving after. */
alreadyHere: boolean;
}DenGuestLeft
A guest leaving the player's own den.
type DenGuestLeft = DenGuestArrival & { leftAt: number }DenPlacedItem
One thing placed in the den on screen (den.DenStateItem).
| Field | Type | |
|---|---|---|
defId | number | |
invIdx | number | Which of the owner's copies it is. |
refId | number | 0 a den item, 1 a pet: the den's save keys an item by this and invIdx. |
position | { x: number; y: number; } | |
flipped | number | Which way round it is drawn; 0 as made. |
layerId | number | |
categoryId | number | The editor's drawer for it (sortCatId). |
userNameLink | string | null | The den a door leads to, by owner; null for none. |
specialType | number | What it does beyond sitting there (DenItemDef.specialType): 1 a door, 5 a den shop… |
DenItemRef
Which placed item: what items() gives, or its refId and invIdx.
| Field | Type | |
|---|---|---|
refId | number | 0 a den item, 1 a pet: the den's save keys an item by this and invIdx. |
invIdx | number | Which of the owner's copies it is. |
DenPlacement
How full the den on screen is, and what the den editor allows.
| Field | Type | |
|---|---|---|
placed | number | How many things are placed (DenItemHolder.numberOfInUseItems). |
limit | number | The most the editor lets the player place: 101, and 200 more for a member. |
warningAt | number | Where the editor starts warning. |
ownDen | boolean | Whether the den is the player's own; the limit is the player's either way. |
DenItemPlacement
Where to put a den item, and which way round.
| Field | Type | |
|---|---|---|
x optional | number | undefined | |
y optional | number | undefined | |
flipped optional | number | undefined |
DenItemSave
One change to save with saveItems: only invIdx is needed, the rest is read off the den.
| Field | Type | |
|---|---|---|
invIdx | number | |
refId optional | number | undefined | |
placed optional | boolean | undefined | In the room, or back to the drawer; in the room when left out. |
x optional | number | undefined | |
y optional | number | undefined | |
flipped optional | number | undefined | |
userNameLink optional | string | undefined |
DenStateChange
One change the den editor saves (DenItemHolder.saveState), as den.state-save carries it.
| Field | Type | |
|---|---|---|
refId | number | What kind of thing it is: 0 a den item, 1 a pet (r). |
invIdx | number | Which of the player's copies it is (i). |
placed | boolean | It is in the room (d is 1); false takes it out, back to the drawer. |
x | number | Where it goes, less the offset the client draws it at; 0 when taken out. |
y | number | |
flipped | number | Which way round it is drawn (f). |
userNameLink | string | The den a den door opens, by owner; empty for none, which the client writes off. |
mannequin | DenMannequinInvIds | null | A mannequin's body and outfit; null for anything else, which the client writes as zeros. |
DenMannequinInvIds
A mannequin as the player's own den item list and the den editor's save carry it (MannequinData.setupDataInvIdsOnly): its body, then each worn item by its place in the player's clothing, 0 for nothing worn there.
type DenMannequinInvIds = DenMannequinLook & {
tailInvId: number;
legInvId: number;
backInvId: number;
neckInvId: number;
headInvId: number;
}DenMannequinLook
A mannequin's body, as MannequinData.setupBodMods reads it before its outfit: the colours, pattern and eyes it is drawn with. A 0 is the avatar def's own default, which the client puts in its place.
| Field | Type | |
|---|---|---|
baseColor | number | The body colour, packed as the client holds it; 0 for the avatar's default. |
patternColor | number | The pattern's colour; 0 for the avatar's default. |
patternDefId | number | The pattern, by def id; 0 for the avatar's default. |
eyeColor | number | The eyes' colour; 0 for the avatar's default. |
eyeDefId | number | The eyes, by def id; 0 for the avatar's default. |
DenServerState
What is in the den on screen, as the server describes it (ds).
| Field | Type | |
|---|---|---|
forceReload | boolean | |
items | DenStateEntry[] | |
pets | DenStatePet[] |
DenStateEntry
One item in the den on screen, as den.state describes it.
| Field | Type | |
|---|---|---|
invIdx | number | Which of the owner's copies it is. |
defId | number | |
placed | boolean | It is in the room (the field is 1): the client gives only these a layer, and -1 the rest. |
x | number | |
y | number | |
version | number | Which of its looks is drawn. |
flipped | number | Which way round it is drawn; 0 as it was made. |
userNameLink | string | null | The den a den door opens, by owner; null when it opens none (the field is null). |
uniqueImageId | string | For a masterpiece, its drawing's own id. |
uniqueImageCreatorDbId | number | For a masterpiece, its creator by account id. |
uniqueImageCreatorUUID | string | For a masterpiece, its creator by account uuid. |
mannequin | DenMannequinOutfit | null | For a mannequin, its body and outfit; null for anything else. |
ecoConsumerStateId | number | For an eco item (ecoConsumerStateId): 0 off, 1 on, 2 on but offline for want of power. |
DenMannequinOutfit
A mannequin as the den's state carries it (MannequinData.setupDataFull): its body, then for each place a def id, followed by the colour and inventory index only when the def id is above 0.
type DenMannequinOutfit = DenMannequinLook & Record<MannequinSlot, DenMannequinWorn>DenStatePet
One pet in the den on screen, as den.state describes it (PetItem.init).
| Field | Type | |
|---|---|---|
invIdx | number | Its place in the owner's pets. |
lBits | number | Its look, packed as PetManager.packPetBits packs it; the low byte is its def id. |
uBits | number | |
eBits | number | |
catId | number | Which layer of the room it is on (DenStateItem.catId). |
x | number | |
y | number | |
flipped | number | |
createdTs | number | When it was adopted, as the server stamps it. |
traitDefId | number | |
toyDefId | number | |
foodDefId | number | |
name | string |
DenEditingState
What the den editor's own editing is doing (room.DenItemHolder).
| Field | Type | |
|---|---|---|
dragging | boolean | |
placed | number | How many things are in the den now. |
saved | number | How many at the last save. |
selected | DenPlacedItem | null | The item last picked up, or null. |
DenHolderState
The holder's own fields: this client's copy of an edit in progress, nothing sent.
| Field | Type | |
|---|---|---|
roomMode | number | 0 ordinary, 1 a den being laid out. |
waitingForFirstItems | boolean | |
lastItemInvId | number | -1 before any. |
itemToEnterInvId | number | |
dragPoint | { x: number; y: number; } | |
themePoint | { x: number; y: number; } | |
glowingInvIdx | number | null | |
selectedInvIdx | number | null | |
keptHelpers | number | |
hasLayers | boolean | |
mannequinEditor | boolean | |
ecoScorePopup | boolean | |
ecoPointsPopup | boolean | |
hasItemRadius | boolean |
Point
| Field | Type | |
|---|---|---|
x | number | |
y | number |
DenEditorState
The den editor as it stands.
| Field | Type | |
|---|---|---|
open | boolean | Whether its drawer is open (isDenHudOpen). |
category | DenEditorCategory | null | |
search | string | |
owned | number | Den items owned that fit this den, and the most the account may own. |
ownedMax | number | |
placed | number | How many are out in the den, the most that may be, and where the warnings start. |
placedMax | number | |
warnAt | number | |
panels | { lock: boolean; music: boolean; shop: boolean; recycle: boolean; } | Which popups are up. |
privacy | { saved: DenPrivacy; chosen: DenPrivacy; } | The den's privacy, and the choice the lock popup is on. |
DenEditorTab
One of the den editor's tabs.
| Field | Type | |
|---|---|---|
category | DenEditorCategory | |
count | number | |
offered | boolean | The client hides the tab of an empty list. |
open | boolean |
DenEditorCategory
One of the den editor's tabs, by the list behind it.
type DenEditorCategory = 'all' | 'furniture' | 'toys' | 'plants' | 'themes' | 'walls' | 'pets'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. |
DenEditorItem
One of the den items (or songs) the den editor lists.
| Field | Type | |
|---|---|---|
index | number | |
invIdx | number | |
defId | number | |
name | string | null | |
placed | boolean | Out in the den (DenItem.categoryId is not 0). |
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). |
DenEditorPanel
A popup or window the den editor opens.
type DenEditorPanel = 'shop' | 'recycle' | 'switchDen' | 'music' | 'lock'DenEditorItemChange
A den item placed from the den editor, or taken back.
| Field | Type | |
|---|---|---|
action | "place" | "remove" | |
invIdx | number | |
defId | number | null | Known for a place; null for a removal, where the client names the item by invIdx alone. |
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'DenEditorButton
type DenEditorButton = | 'customise'
| 'close'
| 'tab'
| 'scrollLeft'
| 'scrollRight'
| 'shop'
| 'recycle'
| 'switchDen'
| 'lock'
| 'lockClose'
| 'music'
| 'musicClose'
| 'musicShop'
| 'musicRecycle'
| 'clearDen'
| 'search'EditorButtonOptions
Whether to hear the mouse moving over buttons as well as pressing them.
| Field | Type | |
|---|---|---|
hover optional | boolean | undefined |
DenInventoryItem
One den item the player owns (den.DenItem), placed or in the editor's drawer.
| Field | Type | |
|---|---|---|
defId | number | |
invIdx | number | Which of the player's copies; -1 for the client's own default music slot. |
refId | number | |
categoryId | number | 0 in the drawer; once placed, the layer of the room it sits on. |
version | number | |
layerId | number | |
sortId | number | The editor's drawer: 0 floor, 1 wall, 4 audio, 99 pet. |
enviroType | number | 0 land, 1 ocean, 3 both. |
name | string | null | Its name in the player's language. |
inDenShop | boolean | Listed in the player's den shop, so it cannot be placed or sold. |
placed | boolean | |
specialType | number |
OwnedDenShop
One of the player's own den shop stands, placed or in the drawer.
| Field | Type | |
|---|---|---|
storeInvId | number | The shop's id, the stand's invIdx, which phantom.aj.denShop takes. |
defId | number | |
name | string | null | |
placed | boolean |
DenItemDefinition
What one den item is, from the def pack (Enums.DenItemDef).
| Field | Type | |
|---|---|---|
defId | number | |
name | string | null | |
nameStrId | number | |
abbrName | string | null | |
cost | number | |
currencyType | number | |
combinedCost | string | null | A price in several currencies (4x10,6x5), or null for one priced in one. |
recycleValue | number | |
membersOnly | boolean | |
itemStatus | number | 0 normal, 1 new, 2 sale, 3 clearance, 4 rare. |
enviroType | number | |
layer | number | |
sortCat | number | |
typeCat | number | |
specialType | number | 0 nothing, 1 portal, 2 emote, 3 den change, 4 mannequin, 5 den shop, 6/7 eco. |
gameDefId | number | null | The minigame it launches, or null. |
listId | number | null | The list it opens, or null. |
isMasterpiece | boolean | |
scalePercent | number | |
ecoPower | number | |
availabilityStartTime | number | null | Seconds since the epoch; null when always for sale / never stopping. |
availabilityEndTime | number | null |
DenItemDefEntry
A den item def as def pack 1030 holds one: text in every field, read by the client through int (DenXtCommManager.denItemDefsResponse). Only id and nameStrId are needed; a field left out is read as the client reads a missing one, 0 or null.
| Field | Type | |
|---|---|---|
id | DefPackValue | |
nameStrId | DefPackValue | |
abbrName optional | string | null | undefined | |
combinedCost optional | string | null | undefined | |
cost optional | DefPackValue | undefined | |
currencyType optional | DefPackValue | undefined | |
enviroType optional | DefPackValue | undefined | |
flag optional | DefPackValue | undefined | |
gameDefId optional | DefPackValue | undefined | |
itemStatus optional | DefPackValue | undefined | |
layer optional | DefPackValue | undefined | |
mannequinAvatarDefId optional | DefPackValue | undefined | |
mannequinCatId optional | DefPackValue | undefined | |
mannequinFrame optional | DefPackValue | undefined | In the pack, but never read: the client gives mannequinCatId where it would go. |
membersOnly optional | DefPackValue | undefined | |
parentArrayId optional | DefPackValue | undefined | |
promoType optional | DefPackValue | undefined | |
recycleValue optional | DefPackValue | undefined | |
scalePercent optional | DefPackValue | undefined | |
sortCat optional | DefPackValue | undefined | |
specialType optional | DefPackValue | undefined | |
typeCat optional | DefPackValue | undefined | |
availabilityStartTime optional | DefPackValue | undefined | |
availabilityEndTime optional | DefPackValue | undefined | |
ecoPower optional | DefPackValue | undefined |
DefPackValue
A field of a def pack entry: text, as the pack holds them, or a number.
type DefPackValue = string | number | nullAddDefinitionOptions
How addDefinition adds a def.
type AddDefinitionOptions = ActOptions & {
/** Put it in place of a def the client already has by that id. Off by default: that throws. */
replace?: boolean;
}DenLimits
The den editor's caps (ShopManager).
| Field | Type | |
|---|---|---|
maxDenItems | number | |
warningDenItemCount | number | |
maxAudioItems | number | |
warningAudioItemCount | number | |
warningDenRoomCount | number |
DenSale
Den items or den rooms sold back (dr).
| Field | Type | |
|---|---|---|
invIdxs | number[] | What was sold, by inventory index. |
gems | number | null | The gem balance afterwards, or null when it did not change. |
DenOwnedItems
Every den item the player owns, as the server lists them (di).
| Field | Type | |
|---|---|---|
activeDenIdx | number | Which den room is the player's den, by its invIdx. |
items | DenOwnedItem[] | |
petsInDen | number[] | The pets placed in the den. |
DenOwnedItem
One den item the player owns, as den.items lists it.
| Field | Type | |
|---|---|---|
invIdx | number | Which of the player's copies it is. |
defId | number | |
categoryId | number | 0 in the drawer; otherwise the layer of the room it is placed on. |
version | number | Which of its looks is drawn, for an item that has several. |
approved | boolean | Whether the item is approved (the field is true): Animal Jam sends it for every item but a masterpiece whose drawing is not approved yet, and the client recycles, or puts on a den shop stand, only an item that is (RecycleItems, DenAndClothesItemSelect). |
uniqueImageId | string | For a masterpiece, its drawing's own id; empty otherwise. |
uniqueImageCreatorDbId | number | For a masterpiece, its creator by account id. |
uniqueImageCreatorUUID | string | For a masterpiece, its creator by account uuid. |
mannequin | DenMannequinInvIds | null | For a mannequin, its body and what it wears; null for anything else. |
denStoreInvId | number | The den shop it is listed in, by that den room's invIdx; 0 when it is in none. |
DenPurchaseHeard
A purchase heard, whoever made it: refusals too, with status other than 1.
type DenPurchaseHeard = DenPurchase & { status: number }EcoState
The den's eco system (EcoStateResponse, dEf).
| Field | Type | |
|---|---|---|
numActiveWindTurbines | number | |
numActiveSolarPanels | number | |
numConsumerItems | number | |
ecoPowerGeneration | number | |
ecoPowerConsumption | number | |
ecoScoreRequired | number | |
nextRewardBitIndex | number | |
unredeemedEcoCredits | number | |
secondsUntilNextEcoCredit | number |
DenEcoConsumer
One eco item's state, as den.eco-consumer-result lists it.
| Field | Type | |
|---|---|---|
invIdx | number | The eco item, by its place in the den. |
stateId | number | Its state (DenStateItem.ecoConsumerStateId), as the eco points popup reads it: 0 off, 1 on, 2 switched on but offline, for want of eco power. |
DenEcoConsumers
The den's eco items after a toggle (dEc).
| Field | Type | |
|---|---|---|
ecoPointsConsumed | number | |
ecoScore | number | |
consumers | DenEcoConsumer[] | Each item the server named: 0 off, 1 on, 2 on but offline. |
EcoPoints
A den eco item's popup (gui.EcoPointsPopup).
| Field | Type | |
|---|---|---|
ready | boolean | |
item | { defId: number; invIdx: number; name: string; } | |
state | "offline" | "off" | "on" | |
consumed | number | |
generated | number | |
infoShown | boolean | |
scoreOpen | boolean |
EcoScore
The den's eco score popup (gui.EcoScorePopup).
| Field | Type | |
|---|---|---|
ready | boolean | |
credits | number | |
unredeemedCredits | number | |
canRedeem | boolean | |
score | number | |
scoreRequired | number | |
generation | number | |
consumption | number | |
giftAvailable | boolean | |
windTurbines | { placed: number; active: number; } | |
solarPanels | { placed: number; active: number; } | |
consumers | { placed: number; active: number; } | |
view | "main" | "info" | "generator" | "consumers" | |
fact | string |
DenSwitcherView
The den switcher (gui.DenSwitcher), as it stands.
| Field | Type | |
|---|---|---|
ready | boolean | |
selected | number | |
pressed | number | |
slots | number | |
counter | string | |
recycling | boolean | |
recyclingOnly | boolean | |
shopOnly | boolean | |
shopOpen | boolean | |
visible | boolean | |
canRecycle | boolean | |
canBuyMore | boolean | |
message | string | null |
DenSlot
One slot of the den switcher.
| Field | Type | |
|---|---|---|
index | number | |
state | "empty" | "unusable" | "den" | |
name | string | null | |
invIdx | number | null | |
defId | number | null | |
memberOnly | boolean | |
selected | boolean | |
recycleMark | boolean | |
drawn | boolean |
SwitcherChange
Something happening on a switcher, told by the client method it happened in.
type SwitcherChange = | { kind: 'ready'; selected: number; slots: number; choosing: boolean }
| { kind: 'slotPressed'; index: number; selected: number; recycling: boolean }
| { kind: 'switched'; ok: boolean }
| { kind: 'added'; ok: boolean; code: number }
| { kind: 'recycled'; ok: boolean; index: number; invId: number | null; gems: number | null }
| { kind: 'bought'; index: number }
| { kind: 'recycling'; on: boolean }
| { kind: 'message'; message: string | null }
| { kind: 'shown'; shown: boolean }