# ScriptType

Class · extends [`Script`](https://api.playcanvas.com/engine/classes/Script.md) · category: Script · deprecated

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/framework/script/script-type.js#L16

This is the legacy format for creating a PlayCanvas script returned when calling `createScript()`.
Do not inherit from this class directly.

**Deprecated**: Use [Script](https://api.playcanvas.com/engine/classes/Script.md) instead.

## Constructors

### constructor

```ts
new ScriptType(args: object)
```

Create a new ScriptType instance.

**Parameters**

- `args` (`object`): The input arguments object.
    - `args.app` ([`AppBase`](https://api.playcanvas.com/engine/classes/AppBase.md)): The AppBase that is running the script.
    - `args.entity` ([`Entity`](https://api.playcanvas.com/engine/classes/Entity.md)): The Entity that the script is attached to.

## Accessors

### attributes

```ts
static get attributes(): ScriptAttributes
```

The interface to define attributes for Script Types. Refer to [ScriptAttributes](https://api.playcanvas.com/engine/classes/ScriptAttributes.md).

**Example**

```ts
var PlayerController = createScript('playerController');

PlayerController.attributes.add('speed', {
    type: 'number',
    title: 'Speed',
    placeholder: 'km/h',
    default: 22.2
});
```

## Methods

### initScript

```ts
protected initScript(args: any): void
```

**Parameters**

- `args` (`any`): initialization arguments

### initScriptType

```ts
protected initScriptType(args: any): void
```

Expose initScript as initScriptType for backwards compatibility

**Parameters**

- `args` (`any`): Initialization arguments

### extend

```ts
static extend(methods: any): void
```

Shorthand function to extend Script Type prototype with list of methods.

**Parameters**

- `methods` (`any`): Object with methods, where key - is name of method, and value - is function.

**Example**

```ts
var PlayerController = createScript('playerController');

PlayerController.extend({
    initialize: function () {
        // called once on initialize
    },
    update: function (dt) {
        // called each tick
    }
});
```

## Inherited from [Script](https://api.playcanvas.com/engine/classes/Script.md)

- `app: AppBase`
- `entity: Entity`
- `get enabled(): boolean` · `set enabled(value: boolean)`
- `static get scriptName(): string | null` · `static set scriptName(value: string | null)`
- `fire(name: string, arg1?: any, arg2?: any, arg3?: any, arg4?: any, arg5?: any, arg6?: any, arg7?: any, arg8?: any): EventHandler`
- `hasEvent(name: string): boolean`
- `off(name?: string, callback?: HandleEventCallback, scope?: any): EventHandler`
- `on(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `once(name: string, callback: HandleEventCallback, scope?: any): EventHandle`
- `static EVENT_ATTR: string = 'attr'`
- `static EVENT_DESTROY: string = 'destroy'`
- `static EVENT_DISABLE: string = 'disable'`
- `static EVENT_ENABLE: string = 'enable'`
- `static EVENT_ERROR: string = 'error'`
- `static EVENT_STATE: string = 'state'`
