Extension Quick Start

Extension Quick Start

Extension Quick Start

Function

This page starts with a calc compute extension example, demonstrating how to create the extension development directory, build the .bts package, install it into the project and call it in main.bt. Users with no basic knowledge are recommended to run through the process according to this page first, and then read Operating Mechanism .

Syntax

quick start will use these commands:

Parameters

ParameterDescription
calcExtended development directory name, will also be used as the default extension.
calc.btsBuild output expansion pack file.
projectThe target BT project directory to install the extension.
main.btProject entry script.

Prepare the project

First prepare a common BT project directory:

main.bt to call the extension:

The calc extension has not been installed at this time. If you run it directly, you will not find calc. The next step is to create the extension.

Create an extension

and execute:

This will generate a pure BT extension development directory:

The default scaffolding already contains a chained calculation object: calc(1).add(2).value().

Build the extension package

and execute it outside the calc directory: When building,

will read manifest.json and bindings.json, check the entry source code, and package the development directory into calc.bts. After

is built, you can check the package information first:

Install into the project

Install the extension into the project directory:

The structure after installation is:

Then run the project in the project directory:

The output should be:

Return Value

bt ext When the command is successful, the creation, build, check or installation results will be output in the terminal; when it fails, a Chinese error will be output. calc(1).add(2).value() in the example script returns the integer 3.

Code Examples

extension object can continue to be called in the chain:

Notes

  • bt ext new calc will generate an extension name based on the directory name. The directory name must use lowercase letters, numbers and underscores, and start with a lowercase letter.
  • bt ext install calc.bts project will copy the package to project/extensions/calc.bts; extensions with the same name will be overwritten.
  • The .bts package under extensions/ will be loaded only when the project is started. The development directory calc/ will not be automatically loaded by the project.
  • If the BT build used for running does not enable the extensions feature, projects that exist in the extensions/ directory will report an error indicating that the extension capability is not available.