Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace ModAPI

Module used to share mods' APIs

Index

Functions

addAPICallback

  • addAPICallback(apiName: string, func: (api: object) => void): void
  • Adds callback for the specified mod API

    Parameters

    • apiName: string

      API name

    • func: (api: object) => void

      callback that is called when API is loaded

        • (api: object): void
        • Parameters

          • api: object

            shared mod API

          Returns void

    Returns void

addModCallback

  • addModCallback(modName: string, func: any): void
  • deprecated

    No longer supported

    Parameters

    • modName: string
    • func: any

    Returns void

addTexturePack

  • addTexturePack(path: any): void

cloneAPI

  • cloneAPI(api: object, deep: boolean): object
  • Recursively opies (duplicates) the object to the new one

    Parameters

    • api: object

      an object to be copied

    • deep: boolean

      if true, copies the object recursively

    Returns object

    a copy of the object

cloneObject

  • cloneObject(source: any, deep: any, rec?: number): object
  • Recursively clones object to the new one counting call depth and interrupting copying after 7th recursion call

    Parameters

    • source: any

      an object to be cloned

    • deep: any

      if true, copies the object recursively

    • Optional rec: number

      current recursion state, if > 6, recursion stops. Default value is 0

    Returns object

    cloned object, all the properties that are less then then 8 in depth, get copied

debugCloneObject

  • debugCloneObject(source: any, deep: any, rec?: number): object | string
  • Parameters

    • source: any
    • deep: any
    • Optional rec: number

    Returns object | string

    same as ModAPI.cloneObject, but if call depth is more then 6, returns "stackoverflow" string value

getModByName

  • getModByName(modName: string): void
  • deprecated

    No longer supported

    Parameters

    • modName: string

    Returns void

getModList

  • getModList(): void

getModPEList

  • getModPEList(): void

inheritPrototypes

  • inheritPrototypes(source: object, target: object): object
  • Ensures target object has all the properties the source object has, if not, copies them from source to target object.

    Parameters

    • source: object

      object to copy missing values from

    • target: object

      object to copy missing values to

    Returns object

isModLoaded

  • isModLoaded(modName: string): void
  • deprecated

    No longer supported

    Parameters

    • modName: string

    Returns void

registerAPI

  • registerAPI(name: string, api: object, descr?: { name?: string; props?: object }): void
  • Registers new API for the mod and invokes mod API callback

    Parameters

    • name: string

      API name used to import it in the other mods

    • api: object

      object that is shared with the other mods. May contain other objects, methods, variables, etc. Sometimes it is useful to provide the ability to run third party code in your own mod, you can create a method that provides such possibility:

      requireGlobal: function(command){
          return eval(command);
      }
    • Optional descr: { name?: string; props?: object }

      simple documentation for the mod API

      • Optional name?: string

        full name of the API, if not specified, name parameter value is used

      • Optional props?: object

        object containing descriptions of methods and properties of the API, where keys are methods and properties names and values are their descriptions

    Returns void

requireAPI

  • requireAPI(name: string): object | null
  • Gets API by its name. The best approach is to call this method in the function passed as the second parameter of ModAPI.addAPICallback.

    Example:

    // importing API registered by IndustrialCraft PE
    var ICore;
    ModAPI.addAPICallback("ICore", function(api){
        ICore = api;
    });

    When using ICore variable from the example, be sure to check it for null because Industrial Craft PE may not be installed on the user's phone

    Parameters

    • name: string

      API name

    Returns object | null

    API object if an API with specified was previously registered, null otherwise

requireAPIPropertyDoc

  • requireAPIPropertyDoc(name: string, prop: string): string | null
  • Fetches information about the method or property of mod API

    Parameters

    • name: string

      API name

    • prop: string

      property or method name

    Returns string | null

    string description of the method or null if no description was provided by API vendor

requireAPIdoc

requireGlobal

  • requireGlobal(name: string): any
  • Executes string in Core Engine's global context. Can be used to get functions and objects directly from AdaptedScriptAPI.

    Parameters

    • name: string

      string to be executed in Core Engine's global context

    Returns any

Generated using TypeDoc