# Interface AI¶

Basic AI interface

## Usage:

require('openmw.interfaces').AI

## Type AI

 AI.filterPackages(filterCallback) Iterate over all packages starting from the active one and remove those where filterCallback returns false. AI.forEachPackage(callback) Iterate over all packages and run callback for each starting from the active one. AI.getActivePackage() Return the currently active AI package (or nil if there are no AI packages). AI.getActiveTarget(packageType) Return the target of the active package if the package has given type AI.getTargets(packageType) Get list of targets of all packages of the given type. AI.removePackages(packageType) Remove packages of given type (remove all packages if the type is not specified). AI.startPackage(options) Start new AI package. AI.version Interface version

## Type Package

 Package.destPosition Destination point of the AI package. Package.sideWithTarget Whether to help the target in combat (true or false). Package.target Target (usually an actor) of the AI package (can be nil). Package.type Type of the AI package.

## Type AI

### Field(s)

AI.filterPackages(filterCallback)

Iterate over all packages starting from the active one and remove those where filterCallback returns false.

### Parameter

• #function filterCallback :

AI.forEachPackage(callback)

Iterate over all packages and run callback for each starting from the active one.

The same as filterPackage, but without removal.

### Parameter

• #function callback :

AI.getActivePackage()

Return the currently active AI package (or nil if there are no AI packages).

### Return value

#Package:

AI.getActiveTarget(packageType)

Return the target of the active package if the package has given type

### Parameter

• #string packageType : The expected type of the active package

### Return value

openmw.core#GameObject: The target (can be nil if the package has no target or has another type)

AI.getTargets(packageType)

Get list of targets of all packages of the given type.

### Parameter

• #string packageType :

### Return value

#list<openmw.core#GameObject>:

AI.removePackages(packageType)

Remove packages of given type (remove all packages if the type is not specified).

### Parameter

• #string packageType : (optional) The type of packages to remove.

AI.startPackage(options)

Start new AI package.

### Parameter

• #table options : See the "Built-in AI packages" page.

#number AI.version

Interface version

## Type Package

AI Package

### Field(s)

openmw.util#Vector3 Package.destPosition

Destination point of the AI package.

#boolean Package.sideWithTarget

Whether to help the target in combat (true or false).

openmw.core#GameObject Package.target

Target (usually an actor) of the AI package (can be nil).

#string Package.type

Type of the AI package.