Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mod

Hierarchy

Index

Constructors

Methods

Constructors

constructor

  • new Mod(index: number): Mod

Methods

addActionType

addBindable

  • Adds a bindable and the default binding for it

    Parameters

    • name: string

      The name of the binding (when translated, the name will be Mod<mod name><name>)

    • binding: IBinding | IBinding[]

      The default binding or bindings of this bindable

    Returns number

addCommand

addCreature

addDictionary

  • addDictionary(name: string, dictionaryEnum: any): number
  • Parameters

    • name: string
    • dictionaryEnum: any

    Returns number

addDoodad

addHairstyle

addItem

addMessage

  • addMessage(name: string, message: string): number
  • Parameters

    • name: string
    • message: string

    Returns number

addMusic

  • addMusic(name: string): number
  • Parameters

    • name: string

    Returns number

addSkillType

addSoundEffect

  • addSoundEffect(name: string, variations?: number): number
  • Parameters

    • name: string
    • Optional variations: number

    Returns number

addTerrain

addTerrainResource

canClientMove

  • Called every frame where the mouse is not hovering over an item

    Parameters

    Returns false | undefined

    False if the player can't move, undefined otherwise

canConsumeItem

  • Called before consuming an item

    Parameters

    Returns boolean | undefined

    True if the player can consume the item (default logic isn't called, should use your own code for consumption), false if the player cannot consume the item, or undefined to use the default logic

canCreatureAttack

  • Called before a creature attacks

    Parameters

    Returns boolean | undefined

    False if the creature cannot attack, or undefined to use the default logic

canCreatureMove

  • Called when a creature tries to move

    Parameters

    • creature: ICreature

      The creature object

    • tile: ITile

      The tile the creature is trying to move to

    • moveType: MoveType

      The creatures move type

    Returns boolean | undefined

    True if the creature can move, false if the creature cannot move, or undefined to use the default logic

canCreatureSpawn

  • canCreatureSpawn(type: CreatureType, x: number, y: number, z: number, aberrant: boolean): boolean | undefined
  • Called when a creature is about to be spawned

    Parameters

    • type: CreatureType

      The type of creature

    • x: number

      The x coordinate where the creature will be spawned

    • y: number

      The y coordinate where the creature will be spawned

    • z: number

      The z coordinate where the creature will be spawned

    • aberrant: boolean

      True if the creature is an aberrant

    Returns boolean | undefined

    False if the creature cannot spawn, or undefined to use the default logic

canDoodadSpawn

  • Called when a doodad is about to be spawned

    Parameters

    • type: DoodadType

      The type of doodad

    • x: number

      The x coordinate where the doodad will be spawned

    • y: number

      The y coordinate where the doodad will be spawned

    • z: number

      The z coordinate where the doodad will be spawned

    • options: IDoodadOptions

      The doodad spawn options

    Returns boolean | undefined

    False if the dooodad cannot spawn, or undefined to use the default logic

canDropItem

  • Called when an item is being dropped

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item to be dropped

    • tile: ITile

      The tile the item will be dropped on

    • dropAll: boolean

      True if all items of this type will be dropped

    • dropAllQuality: ItemQuality | undefined

      If not undefined, all items of this quality will be dropped

    Returns boolean | undefined

    True if the item can be dropped, false if the item can not be dropped, or undefined to use the default logic

canPickupDoodad

  • canPickupDoodad(player: IPlayer, doodad: IDoodad): boolean | undefined
  • Called when an doodad is being picked up

    Parameters

    Returns boolean | undefined

    False if the doodad cannot be picked up, or undefined to use the default logic

canPlayerAttack

  • Called before a player attacks

    Parameters

    • player: IPlayer

      The player object

    • weapon: IItem | undefined

      The weapon used to attack

    • attackType: AttackType

      The attack type

    Returns boolean | undefined

    False if the player cannot attack, or undefined to use the default logic

canSeeCreature

  • canSeeCreature(creature: ICreature, tile: ITile): boolean | undefined
  • Called when calculating creatures in the viewport

    Parameters

    • creature: ICreature

      The creature object

    • tile: ITile

      The tile the creature is on

    Returns boolean | undefined

    False if the player should not see the creature or undefined to use the default logic

createButton

  • createButton(translationId: string, imagePath: string, keyBind?: number): JQuery
  • Parameters

    • translationId: string
    • imagePath: string
    • Optional keyBind: number

    Returns JQuery

createDialog

  • createDialog(container: JQuery, dialogInfo: IDialogInfo): JQuery

createOptionsSection

  • createOptionsSection(creationHandler: function): void

extendLanguage

getAmbientColor

  • getAmbientColor(colors: number[]): number[] | undefined
  • Get the ambient color

    Parameters

    • colors: number[]

      The current ambient colors

    Returns number[] | undefined

    the ambient color channels (3 numbers) or undefined to use the default color

getAmbientColorCave

  • getAmbientColorCave(): number[] | undefined
  • Get the ambient color while in caves

    Returns number[] | undefined

    the ambient color channels (3 numbers) or undefined to use the default color

getAmbientColorDay

  • getAmbientColorDay(): number[] | undefined
  • Get the ambient color while its day time

    Returns number[] | undefined

    the ambient color channels (3 numbers) or undefined to use the default color

getAmbientColorNight

  • getAmbientColorNight(): number[] | undefined
  • Get the ambient color while its night time

    Returns number[] | undefined

    the ambient color channels (3 numbers) or undefined to use the default color

getAmbientLightLevel

  • getAmbientLightLevel(ambientLight: number, z: number): number | undefined
  • Get the ambient light level

    Parameters

    • ambientLight: number

      The current ambient light level

    • z: number

      The world z index

    Returns number | undefined

    the ambient light level or undefined to use the default light level

getButtons

  • getButtons(): JQuery

getCreatureSpriteBatchLayer

  • Called when rendering creatures in the viewport

    Parameters

    Returns SpriteBatchLayer | undefined

    The batch layer the creature should render in or undefined to use the default logic

getDialog

  • getDialog(title: string): JQuery
  • Parameters

    • title: string

    Returns JQuery

getIndex

  • getIndex(): number
  • Returns number

getItemByName

getItemByType

getName

  • getName(): string
  • Returns string

getNextMusicTrack

  • getNextMusicTrack(currentMusicTrack: Music): Music | undefined
  • Called when the next music track is requested

    Parameters

    • currentMusicTrack: Music

      The current music track

    Returns Music | undefined

    The music track that should be played next or undefined to use the default logic

getPath

  • getPath(): string
  • Returns string

getPlayerFieldOfViewRadius

  • getPlayerFieldOfViewRadius(player: IPlayer): number | undefined
  • Called when getting the field of view radius for a player

    Parameters

    • player: IPlayer

      The player object

    Returns number | undefined

    The field of view radius for the player or undefined to use the default logic

getPlayerMaxHealth

  • getPlayerMaxHealth(player: IPlayer): number | undefined
  • Called when getting the players maximum health

    Parameters

    • player: IPlayer

      The player object

    Returns number | undefined

    The maximum health of the player or undefined to use the default logic

getPlayerSpriteBatchLayer

  • Called when rendering the player in the viewport

    Parameters

    Returns SpriteBatchLayer | undefined

    The batch layer the player should render in or undefined to use the default logic

getPlayerWeightMovementPenalty

  • getPlayerWeightMovementPenalty(player: IPlayer): number | undefined
  • Called when getting the players weight movement penalty

    Parameters

    • player: IPlayer

      The player object

    Returns number | undefined

    The weight movement penalty for the player or undefined to use the default logic

getPlayerWeightStatus

  • Called when getting the players weight status

    Parameters

    • player: IPlayer

      The player object

    Returns WeightStatus | undefined

    The weight status of the player or undefined to use the default logic

getTileLightLevel

  • getTileLightLevel(tile: ITile, x: number, y: number, z: number): number | undefined
  • Called when retrieving the light level of a tile

    Parameters

    • tile: ITile

      The tile that was updated

    • x: number

      The x position of the tile

    • y: number

      The y position of the tile

    • z: number

      The z position of the tile

    Returns number | undefined

isPlayerSwimming

  • isPlayerSwimming(player: IPlayer, isSwimming: boolean): boolean | undefined
  • Called when checking if a player is swimming

    Parameters

    • player: IPlayer

      The player object

    • isSwimming: boolean

      True if the player is swimming

    Returns boolean | undefined

    True if the player should be swimming, false if the player should not be swimming, or undefined to use the default logic

isTileInspectable

  • isTileInspectable(tile: ITile): boolean | undefined
  • Called when checking if a tile is inspectable (used for showing custom world tooltips over tiles) Normally used in conjunction with the OnInspectTile hook

    Parameters

    • tile: ITile

      The tile object

    Returns boolean | undefined

    True if you want to show a custom inspect message, false to display no messages, or undefined to use the default logic

itemNameToObjectType

  • itemNameToObjectType(name: string): ItemType | undefined

loadFile

  • loadFile(file: string, callback: function): boolean
  • Parameters

    • file: string
    • callback: function
        • (fileText: string, success: boolean): void
        • Parameters

          • fileText: string
          • success: boolean

          Returns void

    Returns boolean

onBindLoop

  • onBindLoop(bindPressed: true | undefined, api: BindCatcherApi): true | undefined
  • Called when in-game, on the bind catcher loop (once per frame). When overriding this method, make sure you return bindPressed.

    Parameters

    • bindPressed: true | undefined

      Whether a bind has been pressed. Use this as a final check before processing a bind, and set it to true when a bind was pressed.

    • api: BindCatcherApi

      The bind catcher api, allowing you to check whether binds are pressed

    Returns true | undefined

    True if a bind was pressed, undefined otherwise

onBuild

  • Called when something is built on a tile

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item used to build the object

    • tile: ITile

      The tile something was built on

    • doodad: IDoodad

      The doodad that was created on the tile

    Returns void

onButtonBarClick

  • onButtonBarClick(button: JQuery): void
  • Called when a button on the button bar is clicked

    Parameters

    • button: JQuery

      The button element

    Returns void

onContainerItemAdd

  • Called when an item is added to a container.

    Parameters

    • item: IItem

      The item object

    • container: IContainer

      The container object the item was added to. This container might be inventory or a container within the inventory.

    Returns void

onContainerItemRemove

  • Called when an item is removed from a container.

    Parameters

    • item: IItem

      The item object

    • container: IContainer

      The container object the item was removed from.

    Returns void

onContainerItemUpdate

  • Called when an item is moved from one container to another.

    Parameters

    • item: IItem

      The item object

    • containerFrom: IContainer | undefined

      The container object the item was moved to. This container might be inventory or a container within the inventory.

    • containerTo: IContainer

      The container object the item was moved to. This container might be inventory or a container within the inventory.

    Returns void

onCraft

  • Called when an item is crafted

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item that was crafted

    Returns void

onCreateWorld

  • onCreateWorld(world: IWorld): void
  • Called right after the world is created, but before the renderer

    Parameters

    • world: IWorld

      The world object

    Returns void

onCreatureDamage

  • Called when a creature is damaged

    Parameters

    Returns number | undefined

    The amount of damage the creature should take (the creature will take this damage) or undefined to use the default logic

onCreatureDeath

  • Called when a creature dies

    Parameters

    Returns void

onCreatureSpawn

  • Called when a creature spawns

    Parameters

    Returns void

onDisplayMessage

  • onDisplayMessage(message: Message, messageType?: MessageType, ...args: any[]): boolean | undefined
  • Called when a message is about to be displayed to the player

    Parameters

    • message: Message

      The message

    • Optional messageType: MessageType

      The message type

    • Rest ...args: any[]

      The message arguments

    Returns boolean | undefined

    False to not display the message or undefined to use the default logic

onDoodadSpawn

  • onDoodadSpawn(doodad: IDoodad): void
  • Called when a doodad spawns

    Parameters

    • doodad: IDoodad

      The doodad object

    Returns void

onGameEnd

  • Called when the game is ending

    Parameters

    Returns void

onGameStart

  • onGameStart(isLoadingSave: boolean, playedCount: number): void
  • Called when the game is starting

    Parameters

    • isLoadingSave: boolean

      True if a save game was loaded

    • playedCount: number

      The number of times the player has played the game (globally, not per slot)

    Returns void

onGameTickEnd

  • onGameTickEnd(): void
  • Called when the game tick ends

    Returns void

onGameTickStart

  • onGameTickStart(): void
  • Called when the game tick starts

    Returns void

onInitialize

  • onInitialize(saveDataGlobal: any): void
  • Called when the mod is initialized (when it's enabled via the Mod Manager)

    Parameters

    • saveDataGlobal: any

      The save data object you previously saved via onUninitialize()

    Returns void

onInspectTile

  • Called when a tile is being inspected

    Parameters

    • player: IPlayer

      The player object

    • tile: ITile

      The tile being inspected

    Returns IInspect[] | undefined

    The inspects to be shown or undefined to use the default logic

onInventoryItemAdd

  • Called when an item is added to the players inventory

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item object

    • container: IContainer

      The container object the item was added to. This container might be inventory or a container within the inventory.

    Returns void

onInventoryItemRemove

  • Called when an item is removed from the players inventory

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item object

    • container: IContainer

      The container object the item was moved to.

    Returns void

onInventoryItemUpdate

  • Called when an item is moved from one container to another, while still in the players inventory.

    Parameters

    • player: IPlayer

      The player object

    • item: IItem

      The item object

    • container: IContainer

      The container object the item was moved to. This container might be inventory or a container within the inventory.

    Returns void

onItemEquip

  • Called when the player equips an item to a slot

    Parameters

    Returns void

onLoad

  • onLoad(saveData: any): void
  • Called when the mod is loaded. This will be called after a player starts a game (ran before resources & the world are setup)

    Parameters

    • saveData: any

      The save data object you previously saved via onSave()

    Returns void

onMove

  • Called when the player is moving

    Parameters

    • player: IPlayer

      The player object

    • nextX: number

      The x position the player is moving to

    • nextY: number

      The y position the player is moving to

    • tile: ITile

      The tile the player is moving to

    • direction: FacingDirection

      The direction the player is facing

    Returns boolean | undefined

    False to cancel the move or undefined to use the default logic

onMoveComplete

  • onMoveComplete(player: IPlayer): void
  • Called when the player completes a movement

    Parameters

    • player: IPlayer

      The player object

    Returns void

onMoveDirectionUpdate

  • Called when the player faces a different direction

    Parameters

    Returns void

onNoInputReceived

  • onNoInputReceived(player: IPlayer): void
  • Called when no input is received

    Parameters

    • player: IPlayer

      The player object

    Returns void

onPickupDoodad

  • Called when an doodad is picked up

    Parameters

    Returns void

onPlayerDamage

  • Called when a player is damaged

    Parameters

    Returns number | undefined

    The amount of damage the player should take (the player will take this damage) or undefined to use the default logic

onPlayerDeath

  • onPlayerDeath(player: IPlayer): boolean | undefined
  • Called when the player is killed

    Parameters

    • player: IPlayer

      The player object

    Returns boolean | undefined

    False to stop the player from dying or undefined to use the default logic

onPlayerJoin

  • onPlayerJoin(player: IPlayer): void
  • Called when a player joins the server

    Parameters

    • player: IPlayer

      The player object

    Returns void

onPlayerLeave

  • onPlayerLeave(player: IPlayer): void
  • Called when a player leaves the server Note: This hook is not called for the player who left the server (player will never be localPlayer)

    Parameters

    • player: IPlayer

      The player object

    Returns void

onPlayerTickEnd

  • onPlayerTickEnd(player: IPlayer): void
  • Called when the player tick ends

    Parameters

    • player: IPlayer

      The player object

    Returns void

onPlayerTickStart

  • onPlayerTickStart(player: IPlayer): void
  • Called when the player tick starts

    Parameters

    • player: IPlayer

      The player object

    Returns void

onQueueSoundEffect

  • onQueueSoundEffect(type: SfxType, x: number, y: number, z: number): SfxType | boolean | undefined
  • Called when a sound effect is queued

    Parameters

    • type: SfxType

      The sound effect type

    • x: number

      The x location in the world for the effect

    • y: number

      The y location in the world for the effect

    • z: number

      The z location in the world for the effect

    Returns SfxType | boolean | undefined

    False to cancel the sound effect, a sound effect to play instead of the given one, or undefined to use the default logic

onSave

  • onSave(): any
  • Called when the game is saved or the mod is unloaded This will be called before onUnload

    Returns any

    An object containing the data you want to save

onShowInGameScreen

  • onShowInGameScreen(): void
  • Called when the in game screen is shown

    Returns void

onSpawnCreatureFromGroup

  • onSpawnCreatureFromGroup(creatureGroup: SpawnGroup, creaturePool: CreatureType[], x: number, y: number, z: number): boolean | undefined
  • Called when a creature is spawned from a creature group

    Parameters

    • creatureGroup: SpawnGroup

      The creature group

    • creaturePool: CreatureType[]

      The pool of creatures that can be spawned

    • x: number

      The x position to spawn the creature

    • y: number

      The y position to spawn the creature

    • z: number

      The z position to spawn the creature

    Returns boolean | undefined

    False to cancel spawning the creature or undefined to use the default logic

onTileUpdate

  • onTileUpdate(tile: ITile, x: number, y: number, z: number): void
  • Called when a tile is updated (tile type changed, doodad created on it, etc)

    Parameters

    • tile: ITile

      The tile that was updated

    • x: number

      The x position to spawn the creature

    • y: number

      The y position to spawn the creature

    • z: number

      The z position to spawn the creature

    Returns void

onTurnEnd

  • Called when a turn is ending

    Parameters

    • player: IPlayer

      The player object

    Returns void

onTurnStart

  • onTurnStart(player: IPlayer): void
  • Called when a turn is starting

    Parameters

    • player: IPlayer

      The player object

    Returns void

onUninitialize

  • onUninitialize(): any
  • Called before the mod is uninitialized (when it's disabled via the Mod Manager)

    Returns any

    An object containing the data you want to save (saved globally, not per slot)

onUninitialized

  • onUninitialized(): any
  • Called after the mod is uninitialized

    Returns any

onUnload

  • onUnload(): void
  • Called when the mod is unloaded

    Returns void

onUpdateWeight

  • onUpdateWeight(player: IPlayer, newWeight: number): number | undefined
  • Called when the players weight is being updated

    Parameters

    • player: IPlayer

      The player object

    • newWeight: number

      The new weight of the player

    Returns number | undefined

    A number to set the player weight to or undefined to use the default logic

postExecuteAction

  • Called after an action has been executed This is called after the action result is used

    Parameters

    Returns void

postGenerateWorld

  • postGenerateWorld(generateNewWorld: boolean): void
  • Called after the world is generating

    Parameters

    • generateNewWorld: boolean

      True if a new world is being generated

    Returns void

postRender

  • postRender(): void
  • Called after rendering everything

    Returns void

postRenderPostProcess

  • postRenderPostProcess(): void
  • Caller after post processing the world render

    Returns void

postRenderWorld

  • postRenderWorld(tileScale: number, viewWidth: number, viewHeight: number): void
  • Caller after rendering the world

    Parameters

    • tileScale: number

      The tile scale

    • viewWidth: number

      The width of the view port

    • viewHeight: number

      The height of the view port

    Returns void

preExecuteAction

  • Called before an action is executed This is called before the action result is used

    Parameters

    Returns boolean | undefined

    False to cancel the action or undefined to use the default logic

preExecuteCommand

  • preExecuteCommand(player: IPlayer, command: Command, args: string): boolean | undefined
  • Called before a command is executed

    Parameters

    • player: IPlayer

      The player object

    • command: Command

      The command

    • args: string

      The arguments

    Returns boolean | undefined

    False to cancel the command or undefined to use the default logic

preRender

  • preRender(): void
  • Called before rendering everything

    Returns void

preRenderPostProcess

  • preRenderPostProcess(): void
  • Caller before post processing the world render

    Returns void

preRenderWorld

  • preRenderWorld(tileScale: number, viewWidth: number, viewHeight: number): void
  • Called before rendering the world

    Parameters

    • tileScale: number

      The tile scale

    • viewWidth: number

      The width of the view port

    • viewHeight: number

      The height of the view port

    Returns void

processInput

  • processInput(player: IPlayer): boolean | undefined
  • Called when input is being processed

    Parameters

    • player: IPlayer

      The player object

    Returns boolean | undefined

    False to prevent input processing or undefined to use the default logic

registerPacket

removeButton

  • removeButton(button: JQuery): void
  • Parameters

    • button: JQuery

    Returns void

shouldRender

  • Called when different object types are rendered

    Returns RenderFlag | undefined

    A bitwise list of render flags or undefined to use the default logic

unallocate

  • unallocate(): void
  • This is called internally after unloading a mod

    Returns void

Generated using TypeDoc