Options
All
  • Public
  • Public/Protected
  • All
Menu

Module used to share mods' APIs

Index

Functions

  • 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

          Returns void

    Returns void

  • addModCallback(modName: string, func: any): void
  • addTexturePack(path: any): void
  • cloneAPI(api: object, deep: boolean): object
  • Recursively copies (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(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(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(modName: string): void
  • getModList(): void
  • getModPEList(): void
  • 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(modName: string): void
  • 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(name: string): Nullable<object>
  • 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 Nullable<object>

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

  • requireAPIPropertyDoc(name: string, prop: string): Nullable<string>
  • Fetches information about the method or property of mod API

    Parameters

    • name: string

      API name

    • prop: string

      property or method name

    Returns Nullable<string>

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

  • 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