Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Mod

Hierarchy

Implements

Index

Constructors

constructor

  • new Mod(index: number): Mod
  • Parameters

    • index: number

    Returns Mod

Properties

Readonly event

event: IEventEmitter<this, IModEvents> = new EventEmitter<this, E>(this)

Methods

getIndex

  • getIndex(): number
  • Returns number

getLog

  • getLog(): Log

getName

  • getName(): string
  • Returns the name of this mod.

    Returns string

getPath

  • getPath(): string
  • Returns string

getPrefix

  • getPrefix(): string
  • Returns the prefix for this mod used in registrations. Example: A mod named Debug Tools would be ModDebugTools

    Returns string

getRegistryName

  • getRegistryName(name: string): string
  • Returns the full registry name for the given registration name, concatenating the mod registration prefix. Example: A mod named Debug Tools registering Cool Thingy would be ModDebugToolsCoolThingy

    Parameters

    • name: string

    Returns string

initializeGlobalData

  • initializeGlobalData(data: any): any
  • Called when the global data for this mod is retrieved from a field decorated with @Mod.globalData.

    Parameters

    • data: any

      Any existing data, or undefined

    Returns any

    The data that should be returned. Conventionally, this is an object of some kind. It must be JSON serializable.

    This method is meant to be overridden. It is called internally.

initializeSaveData

  • initializeSaveData(data: any): any
  • Called when the save data for this mod is retrieved from a field decorated with @Mod.saveData.

    Parameters

    • data: any

      Any existing data, or undefined

    Returns any

    The data that should be returned. Conventionally, this is an object of some kind. It must be JSON serializable.

    This method is meant to be overridden. It is called internally.

isPlayerSwimming

  • isPlayerSwimming(human: Human, isSwimming: boolean): boolean | undefined
  • Parameters

    • human: Human
    • isSwimming: boolean

    Returns boolean | undefined

loadFile

  • loadFile(file: string, callback: (fileText: string, success: boolean) => void): boolean
  • Parameters

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

          • fileText: string
          • success: boolean

          Returns void

    Returns boolean

onBuild

  • Parameters

    Returns void

onCraft

  • Parameters

    Returns void

onCreateWorld

  • onCreateWorld(world: IWorld): void
  • Parameters

    Returns void

onCreatureDamage

  • Parameters

    Returns number | undefined

onCreatureDeath

  • onCreatureDeath(creature: Creature): void
  • Parameters

    Returns void

onCreatureSpawn

  • onCreatureSpawn(creature: Creature): void
  • Parameters

    Returns void

onCreatureTamed

  • Parameters

    Returns void

onDisplayMessage

  • Parameters

    Returns void

onDoodadSpawn

  • onDoodadSpawn(doodad: Doodad): void
  • Parameters

    Returns void

onEntityKill

  • Parameters

    Returns void

onGameScreenVisible

  • onGameScreenVisible(): void
  • Returns void

onGameStart

  • onGameStart(isLoadingSave: boolean, playedCount: number): void
  • Parameters

    • isLoadingSave: boolean
    • playedCount: number

    Returns void

onGameTickEnd

  • onGameTickEnd(): void
  • Returns void

onGameTickStart

  • onGameTickStart(): void
  • Returns void

onHumanSkillChange

  • onHumanSkillChange(human: Human, skill: SkillType, currentSkill: number): void
  • Parameters

    Returns void

onInitialize

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

    Returns void

onItemDamage

  • onItemDamage(item: Item, modifier?: undefined | number): number | undefined
  • Parameters

    • item: Item
    • Optional modifier: undefined | number

    Returns number | undefined

onItemEquip

  • Parameters

    Returns void

onItemQuickslot

  • onItemQuickslot(item: Item, player: Player, quickSlot: number | undefined): void
  • Parameters

    • item: Item
    • player: Player
    • quickSlot: number | undefined

    Returns void

onLanguageChange

  • onLanguageChange(languageName: string): void
  • Parameters

    • languageName: string

    Returns void

onLoad

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

    Returns void

onMove

  • onMove(player: Player, nextX: number, nextY: number, tile: ITile, direction: Direction): boolean | undefined
  • Parameters

    Returns boolean | undefined

onMoveDirectionUpdate

  • Parameters

    Returns void

onNPCDamage

  • Parameters

    Returns number | undefined

onNPCDeath

  • onNPCDeath(npc: NPC): boolean | undefined
  • Parameters

    Returns boolean | undefined

onNPCSpawn

  • onNPCSpawn(npc: NPC): void
  • Parameters

    Returns void

onOpenBook

  • Parameters

    Returns void

onPickupDoodad

  • Parameters

    Returns void

onPlayerJoin

  • onPlayerJoin(player: Player): void
  • Parameters

    Returns void

onPlayerLeave

  • onPlayerLeave(player: Player): void
  • Parameters

    Returns void

onQueueSoundEffect

  • onQueueSoundEffect(type: SfxType, x: number, y: number, z: number): SfxType | boolean | undefined
  • Parameters

    • type: SfxType
    • x: number
    • y: number
    • z: number

    Returns SfxType | boolean | undefined

onRenderOverlay

  • Parameters

    Returns void

onSailToCivilization

  • onSailToCivilization(player: Player): void
  • Parameters

    Returns void

onSpawnCreatureFromGroup

  • onSpawnCreatureFromGroup(creatureGroup: SpawnGroup, creaturePool: CreatureType[], x: number, y: number, z: number): boolean | undefined
  • Parameters

    Returns boolean | undefined

onTurnEnd

  • onTurnEnd(player: Player): void
  • Parameters

    Returns void

onTurnStart

  • onTurnStart(player: Player): void
  • Parameters

    Returns void

onUninitialize

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

    Returns void

onUninitialized

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

    Returns void

onUnload

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

    Returns void

onUpdateWeight

  • onUpdateWeight(player: Player, newWeight: number): number | undefined
  • Parameters

    • player: Player
    • newWeight: number

    Returns number | undefined

postExecuteAction

postFieldOfView

  • postFieldOfView(): void
  • Returns void

postGenerateWorld

  • postGenerateWorld(generateNewWorld: boolean): void
  • Parameters

    • generateNewWorld: boolean

    Returns void

postRender

  • postRender(): void
  • Returns void

postRenderPostProcess

  • postRenderPostProcess(): void
  • Returns void

postRenderWorld

  • postRenderWorld(tileScale: number, viewWidth: number, viewHeight: number): void
  • Parameters

    • tileScale: number
    • viewWidth: number
    • viewHeight: number

    Returns void

preExecuteAction

preExecuteCommand

  • preExecuteCommand(player: Player, command: Command, args: string | undefined): boolean | undefined
  • Parameters

    Returns boolean | undefined

preLoadWorldDifferences

  • preLoadWorldDifferences(generateNewWorld: boolean): void
  • Parameters

    • generateNewWorld: boolean

    Returns void

preRender

  • preRender(): void
  • Returns void

preRenderPostProcess

  • preRenderPostProcess(): void
  • Returns void

preRenderWorld

  • preRenderWorld(tileScale: number, viewWidth: number, viewHeight: number): void
  • Parameters

    • tileScale: number
    • viewWidth: number
    • viewHeight: number

    Returns void

processInput

  • processInput(player: Player): boolean | undefined
  • Parameters

    Returns boolean | undefined

Protected registerEventHandlers

  • registerEventHandlers(...untilEvents: Array<keyof Events<this>>): void
  • Registers event handlers, injections, and bind handlers. This is called on the preLoad event by default, and the handlers are deregistered on the unload event.

    If you call this manually before preLoad, it won't be called on preLoad and it won't deregister on unload.

    Please note that registering handlers when the mod is initialized means that the handlers will remain registered even when the user is playing on a server that doesn't support the mod.

    Parameters

    • Rest ...untilEvents: Array<keyof Events<this>>

    Returns void

shouldCraft

shouldDisplayMessage

  • shouldDisplayMessage(player: Player, message: IMessage, messageId: number): boolean | undefined
  • Parameters

    Returns boolean | undefined

shouldRender

  • Returns RenderFlag | undefined

Static getMod

  • getMod(clsOrMod: Class<any> | Mod, modName?: undefined | string): any
  • Parameters

    • clsOrMod: Class<any> | Mod
    • Optional modName: undefined | string

    Returns any

Static globalData

  • globalData<M>(): <K, T>(target: T, key: K) => void
  • globalData<M>(name: string): <K, T>(target: T, key: K) => void
  • Injects the global data for this mod.

    Type parameters

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

  • Injects the global data for a mod by its name or class.

    Type parameters

    Parameters

    • name: string

      Given a mod name, the decorated field will be injected with global data from the enabled/loaded instance of the mod by that name.

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

Static instance

  • instance<M>(): <K, T>(target: T, key: K) => void
  • instance<M>(name: string): <K, T>(target: T, key: K) => void
  • Injects the decorated field with this mod's instance.

    Type parameters

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

  • Injects the decorated field with a mod instance.

    Type parameters

    Parameters

    • name: string

      Given a mod name, the decorated field will be injected with the enabled/loaded instance of the mod by that name.

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

Static log

  • log(): <K, T>(target: T, key: K) => void
  • log(name?: undefined | string): <K, T>(target: T, key: K) => void
  • Injects the decorated field with this mod's log.

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

  • Injects the decorated field with a mod's log.

    Parameters

    • Optional name: undefined | string

      Given a mod name, the decorated field will be injected with the log of the enabled/loaded mod by that name.

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

Static saveData

  • saveData<M>(): <K, T>(target: T, key: K) => void
  • saveData<M>(name: string): <K, T>(target: T, key: K) => void
  • Injects the save data for this mod.

    Type parameters

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

  • Injects the save data for a mod by its name or class.

    Type parameters

    Parameters

    • name: string

      Given a mod name, the decorated field will be injected with save data from the enabled/loaded instance of the mod by that name.

    Returns <K, T>(target: T, key: K) => void

      • <K, T>(target: T, key: K): void
      • Type parameters

        • K: string | number | symbol

        • T: {}

        Parameters

        • target: T
        • key: K

        Returns void

Generated using TypeDoc