Namespace ModAPI

Module used to share mods' APIs.

Functions

  • Adds callback for the specified mod API.

    Parameters

    • apiName: string

      API name from ModAPI.registerAPI call

    • func: ((api: object) => void)

      callback that is called when API is loaded

        • (api): void
        • Parameters

          • api: object

            shared mod API

          Returns void

    Returns void

  • Parameters

    • modName: string
    • func: any

    Returns void

    No longer supported.

  • Parameters

    • path: any

    Returns void

    No longer supported.

  • Recursively copies (duplicates) the value to the new one.

    Type Parameters

    • T

    Parameters

    • api: T

      an object to be copied

    • Optionalrecursive: boolean

      if true, copies the object recursively

    Returns T

    A copy of the object.

  • Recursively clones object to the new one counting call depth and interrupting copying after 7th recursion call.

    Type Parameters

    • T extends object

    Parameters

    • source: T

      an object to be cloned

    • Optionalrecursive: boolean

      if true, copies the object recursively

    • Optionaldepth: number

      current recursion state, if > 6, recursion stops; default value is 0

    Returns T

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

  • Same as ModAPI.cloneObject, but if call depth is more then 6, inserts "stackoverflow" string value otherwise.

    Type Parameters

    • T

    Parameters

    • source: T
    • Optionalrecursive: boolean
    • Optionaldepth: number

    Returns T | string

  • Parameters

    • modName: string

    Returns void

    No longer supported.

  • Returns string[]

    No longer supported.

  • Returns string[]

    No longer supported.

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

    Type Parameters

    • K extends object
    • T extends object

    Parameters

    • source: K

      object to copy missing values from

    • target: T

      object to copy missing values to

    Returns K & T

  • Parameters

    • modName: string

    Returns void

    No longer supported.

  • 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.

    • Optionaldescr: {
          name?: string;
          props?: object;
      }

      simple documentation for the mod API

      • Optionalname?: string

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

      • Optionalprops?: object

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

        Writing documentation that way is not recommended.

    Returns void

    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(command) {
    return eval(command);
    }
  • Gets API by it's name. The best approach is to call this method in the function passed as the second parameter of ModAPI.addAPICallback.

    Parameters

    Returns Nullable<object>

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

    Importing API registered by IndustrialCraft PE:

    let ICore = null;
    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.

  • Fetches information about the method or property of mod API.

    Parameters

    Returns Nullable<string>

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

    Writing documentation that way is not recommended.

  • Executes string in Core Engine's global context. Can be used to get functions and objects directly from Adapted Script.

    Parameters

    • name: string

      string to be executed in Core Engine's global context

    Returns any

    null if execution failed or appropriate variable same.

Variables

modAPIs: {
    [name: string]: {
        api: string;
        descr: ModDocumentation;
    };
}

Collects registered APIs objects, use ModAPI.requireAPI to directly access required instance.

Copyright © 2024 Nernar. Copyright © 2020 #mineprogramming. Built with ❤ and TypeDoc.