Early development: IFLoom can change until 1.0. What's stable
IFLoom

@ifloom/plugin-cast

Every export of @ifloom/plugin-cast and its /react subpath: its signature and its fields.

Generated from the source of @ifloom/plugin-cast and @ifloom/plugin-cast/react and its TSDoc by npm run api-docs. Each export links to the page that explains it, where one does.

@ifloom/plugin-cast

AWAY

Const. Explained in Cast.

The location id a person is at when they are at no location, 'away'. A person without home is here when no schedule entry holds.

import { AWAY } from '@ifloom/plugin-cast'
const AWAY: 'away'

cast

Function. Explained in Cast.

Returns the cast plugin, for the game's plugins. It cooperates with places, which says where the player is, and with the calendar, which a schedule can ask.

Its helpers write people and calls, such as cast.person({ ... }), cast.talk('ava') and cast.call('ava').

import { cast } from '@ifloom/plugin-cast'
function cast(options?: CastOptions): DefinedPlugin<null, CastView>

Uses: CastOptions, DefinedPlugin, CastView.

HelperSignatureDescription
cast.person(def: PersonDef): EntityDefReturns an entity of the kind character (or of) carrying the cast/person trait, for content's entities. It takes a PersonDef, the entity's fields and the trait's side by side.
cast.character(who: string, kind?: string): EntityRefReturns the entity reference of a person, such as 'character:ava' for cast.character('ava'). Pass kind for a cast of another kind.
cast.talk(who: string): CommandRefReturns the cast/talk command, which opens the person's talk scene while they are here.
cast.call(who: string): CommandRefReturns the cast/call command, which opens the person's call scene from anywhere.
cast.here(...who: string[]): ConditionReturns the cast/here condition, which holds while any of the people named is at the player's location.
cast.at(who: string, ...places: string[]): ConditionReturns the cast/at condition, which holds while the person is at any of the locations named.
cast.met(...who: string[]): ConditionReturns the cast/met condition, which holds once the player has met any of the people named.

CastContact

Type. Explained in Cast.

A character the player can call, as the cast/contacts query answers.

import type { CastContact } from '@ifloom/plugin-cast'
type CastContact = {
  id: string
  name: string
  description: string | null
  image: string | null
  portrait: string | null
  command: CommandRef
  disabled: string | undefined
}
FieldTypeOptionalDefaultDescription
idstringThe character's id, as the cast names them, such as 'ava'.
namestringThe character's name.
descriptionstring | nullThe character's description, a line about them, or null.
imagestring | nullThe character's picture, through artSrc, or null.
portraitstring | nullThe character's face for a small avatar, or null.
commandCommandRefThe cast's cast/call command for the character, in the short form.
disabledstring | undefinedThe reason the call can't go through now, or undefined when it can.

CastOptions

Type. Explained in Cast.

Settings for cast(). Every field is optional and has the default its comment gives.

import type { CastOptions } from '@ifloom/plugin-cast'
type CastOptions = {
  kind?: string
}
FieldTypeOptionalDefaultDescription
kindstringyesThe kind the plugin brings for its people, which a bare id names ('ava' is 'character:ava'). character if left out.

CastView

Type. Explained in Cast.

The cast as the player sees it, in view.plugins.cast.

import type { CastView } from '@ifloom/plugin-cast'
type CastView = {
  present: PersonView[]
  people: PersonView[]
}
FieldTypeOptionalDefaultDescription
presentPersonView[]The people at the location the player is at. Empty while a scene is open or a lock that denies everything is on.
peoplePersonView[]The people the player has met, in the order of peopleOf.

peopleOf

Function. Explained in Cast.

Returns the entity references of every person in the game now, the entities carrying the cast/person trait. Content's people come first in declared order, then those made in play.

import { peopleOf } from '@ifloom/plugin-cast'
function peopleOf(state: GameState, game: Game): EntityRef[]

Uses: GameState, Game, EntityRef.

Person

Type. Explained in Cast.

The data the cast/person trait holds, which makes an entity a person the player can meet, find and talk to. cast.person({ ... }) writes it beside the entity's own fields.

import type { Person } from '@ifloom/plugin-cast'
type Person = {
  fullName?: string
  pronouns?: Record<string, string>
  home?: string
  schedule?: { location: string; when?: Condition }[]
  talk?: string | TalkOption[]
  call?: { scene?: string; when?: Condition; busy?: string }
  storyline?: string
  met?: Condition
  portrait?: string
}
FieldTypeOptionalDefaultDescription
fullNamestringyesThe person's full name, with prose tokens filled in. The entity's name if left out.
pronounsRecord<string, string>yesThe person's pronouns for prose, such as { they: 'she', them: 'her' }. The engine gives them no meaning.
homestringyesThe id of the location the person is at when no schedule entry holds. AWAY, which is no location, if left out.
schedule{ location: string; when?: Condition }[]yesThe person's schedule, each entry a location and its condition. The first entry whose when holds places them, with '$' as the person.
talkstring | TalkOption[]yesThe scene that talking to the person opens, or several options of which the first whose when holds opens. The person can't be talked to if left out.
call{ scene?: string; when?: Condition; busy?: string }yesThe settings for calling the person from anywhere. The person can't be called if left out. scene is the scene a call opens, the talk scene if left out. when is the condition for picking up, and busy is the reason shown while it doesn't hold.
storylinestringyesThe person's storyline. While it is closed, the person won't talk or pick up.
metConditionyesThe condition for the player having met the person. Having seen one of their talk or call scenes if left out.
portraitstringyesThe person's face for avatars, a path in the game's art/ folder. The entity's image if left out. A UI shows it where it renders the person small, such as in a thread, a post or a contact.

PersonDef

Type. Explained in Cast.

A person the game declares in entities with cast.person({ ... }). It holds an entity's fields and the cast/person trait's side by side.

The entity's description is the line under the person's name, such as "Runs the café", and its image is their picture.

import type { PersonDef } from '@ifloom/plugin-cast'
type PersonDef = {
  fullName?: string
  pronouns?: Record<string, string>
  home?: string
  schedule?: { location: string; when?: Condition }[]
  talk?: string | TalkOption[]
  call?: { scene?: string; when?: Condition; busy?: string }
  storyline?: string
  met?: Condition
  portrait?: string
  of?: string
  // …
}

Plugins add fields of their own to it, which their pages list.

FieldTypeOptionalDefaultDescription
fullNamestringyesThe person's full name, with prose tokens filled in. The entity's name if left out.
pronounsRecord<string, string>yesThe person's pronouns for prose, such as { they: 'she', them: 'her' }. The engine gives them no meaning.
homestringyesThe id of the location the person is at when no schedule entry holds. AWAY, which is no location, if left out.
schedule{ location: string; when?: Condition }[]yesThe person's schedule, each entry a location and its condition. The first entry whose when holds places them, with '$' as the person.
talkstring | TalkOption[]yesThe scene that talking to the person opens, or several options of which the first whose when holds opens. The person can't be talked to if left out.
call{ scene?: string; when?: Condition; busy?: string }yesThe settings for calling the person from anywhere. The person can't be called if left out. scene is the scene a call opens, the talk scene if left out. when is the condition for picking up, and busy is the reason shown while it doesn't hold.
storylinestringyesThe person's storyline. While it is closed, the person won't talk or pick up.
metConditionyesThe condition for the player having met the person. Having seen one of their talk or call scenes if left out.
portraitstringyesThe person's face for avatars, a path in the game's art/ folder. The entity's image if left out. A UI shows it where it renders the person small, such as in a thread, a post or a contact.
ofstringyesThe person's kind. The cast's own kind (character, or the kind option) if left out.

personOf

Function. Explained in Cast.

Returns the cast/person trait of the entity ref, or undefined when it isn't a person. It reads through an entity made in play like another.

import { personOf } from '@ifloom/plugin-cast'
function personOf(state: GameState, game: Game, ref: EntityRef): Person | undefined

Uses: GameState, Game, EntityRef, Person.

PersonView

Type. Explained in Cast.

A person as the player sees them, in view.plugins.cast. Names and descriptions have their prose tokens filled in.

import type { PersonView } from '@ifloom/plugin-cast'
type PersonView = {
  id: string
  ref: EntityRef
  name: string
  fullName: string
  description: string | null
  ui?: Ui<EntityUi>
  image: string | null
  portrait: string | null
  here: boolean
  closed: boolean
  met: boolean
  actions: RenderedChoice[]
}
FieldTypeOptionalDefaultDescription
idstringThe person's id, as cast.talk('ava') names them. It's the whole reference for a person of a kind other than the cast's.
refEntityRefThe person's entity reference, such as 'character:ava'.
namestringThe person's name from their entity.
fullNamestringThe person's full name, or their name when they have none.
descriptionstring | nullThe person's entity description, such as "Runs the café", or null when there is none.
uiUi<EntityUi>yesThe person's entity presentation hints, such as the React UI's hue. Left out when there are none.
imagestring | nullThe person's picture's path, through artSrc. It's the entity's image, else <kind>/<id>. The type allows null, as every plugin's picture does, though the cast always gives a path.
portraitstring | nullThe person's face for avatars, through artSrc. It's the trait's portrait, else their image.
herebooleanTrue when the person's schedule puts them at the location the player is at (places/here).
closedbooleanTrue while the person's storyline is closed.
metbooleanTrue when the player has met the person, by their met condition, else by having seen one of their talk or call scenes.
actionsRenderedChoice[]The person's talk action, refused with its reason when it can't run. Empty when the person has no talk.

SenderView

Type. Explained in Cast.

The sender of a message or a post, as the cast/sender query answers.

import type { SenderView } from '@ifloom/plugin-cast'
type SenderView = {
  name: string
  image: string | null
  portrait: string | null
}
FieldTypeOptionalDefaultDescription
namestringThe sender's name.
imagestring | nullThe sender's picture, or null.
portraitstring | nullThe sender's face for a small avatar, a person's portrait, or null.

TalkOption

Type. Explained in Cast.

A way a conversation with a person can open, one entry of a person's talk. The first entry whose when holds opens.

import type { TalkOption } from '@ifloom/plugin-cast'
type TalkOption = {
  scene: string
  when?: Condition
  label?: string
}
FieldTypeOptionalDefaultDescription
scenestringThe id of the scene the conversation opens.
whenConditionyesThe option's condition, with '$' as the person. The option always holds if left out.
labelstringyesThe talk button's label for this option. The cast/talk string ("Talk") if left out.

@ifloom/plugin-cast/react

CAST_WORDS

Const. Explained in Cast.

The cast plugin's words in English, keyed by name. A game rewords any of them with ui.<key> in its strings.

import { CAST_WORDS } from '@ifloom/plugin-cast/react'
const CAST_WORDS: { readonly people: 'People'; }

castUi

Const. Explained in Cast.

The cast plugin's React UI, for plugins on mountGame or GameProvider. It adds PeopleSection to the sidebar, PeopleHere to the story after the room's actions, the people panel and the plugin's words.

import { castUi } from '@ifloom/plugin-cast/react'
const castUi: PluginUi

Uses: PluginUi.

PeopleHere

Const. Explained in Cast.

Renders the people at the player's location from view.plugins.cast.present, each with their actions. A preset styles its people, person, person-portrait, person-name, person-desc and person-actions parts.

It renders nothing in a game without the plugin, or while nobody is here.

import { PeopleHere } from '@ifloom/plugin-cast/react'
const PeopleHere: ComponentType<{ className?: string; }>

PeopleSection

Component. Explained in Cast.

Renders the default layout's People section, a button that opens Relationships in a dialog. Its title is the people word.

import { PeopleSection } from '@ifloom/plugin-cast/react'
function PeopleSection(): JSX.Element

Relationships

Const. Explained in Cast.

Renders everyone the player has met from view.plugins.cast.people, each with the stats the view lists on their entity, such as friendship. A preset styles its relationships, relationship, relationship-header and relationship-stats parts.

It renders nothing in a game without the plugin, or before the player has met anyone.

import { Relationships } from '@ifloom/plugin-cast/react'
const Relationships: ComponentType<{ className?: string; }>

usePeople

Function. Explained in Cast.

Returns the cast plugin's view from the running game, or null in a game without the plugin. It re-renders when the view changes.

The view lists the people here in present, each with their actions, and everyone met in people. PeopleHere and Relationships render from it.

import { usePeople } from '@ifloom/plugin-cast/react'
function usePeople(): CastView | null

Uses: CastView.

Last updated on

On this page