Addon ID

  • behavior_template

Info

Statistics

  • Download count11 total downloads
  • Latest download count 11 downloads of latest version
  • Average download count1 downloads per day average

Owners

# Behavior Template — Documentation

**Version:** 1.0.0.0 | Construct 3 SDK v2

---if you want buy me a coffe! buymeacoffee.com/fallout2remake

## User Guide

**Installation:** Menu → View → Addon Manager → Install new addon → select `.c3addon`

**Adding to object:** Select a Sprite → Properties panel → Behaviors → Add behavior → Behavior Template

### Properties (editor panel)

| Property | Default | Description |

|----------|---------|-------------|

| Enabled | ✓ | Whether the behavior is active on start |

### Actions

| Action | Parameter | Description |

|--------|-----------|-------------|

| Set Enabled | Boolean | Enable or disable the behavior at runtime |

### Conditions

| Condition | Description |

|-----------|-------------|

| Is Enabled | True when the behavior is enabled |

**Event example:**

```

On Button clicked

→ Behavior Template: Set enabled to True

Behavior Template: Is enabled

→ Sprite: Set visible

```

---

## Developer Guide

**File structure:**

```

addon.json — metadata

aces.json — ACE definitions (actions, conditions, expressions)

editor.js — editor: behavior + type + instance classes, properties

icon.svg — icon shown in C3 editor

lang/en-US.json — display names and descriptions

c3runtime/main.js — runtime: all logic in one file

(instance, Acts, Cnds, Exps, Type, Plugin)

```

**Adding an Action** (3 files):

`aces.json` → add to `actions` array with `id`, `scriptName`, optional `params`

`lang/en-US.json` → add display name under `actions`

`c3runtime/main.js` → add function to `Acts` object matching `scriptName`

**Adding a Condition** (3 files):

`aces.json` → add to `conditions` array

`lang/en-US.json` → add display name under `conditions`

`c3runtime/main.js` → add function to `Cnds` object, must return `true`/`false`

**Adding an Expression** (3 files):

`aces.json` → add to `expressions` array with `returnType` (`number`, `string`, `any`)

`lang/en-US.json` → add entry under `expressions` with `translated-name`

`c3runtime/main.js` → add function to `Exps` object, must return a value

**Adding a property (editor panel):**

`editor.js` → add `new SDK.PluginProperty(type, id, options)` to `SetProperties([])`

`lang/en-US.json` → add entry under `properties`

`c3runtime/main.js` → read via `this._getInitProperties()[index]` in constructor

**Per-tick logic:**

```js

_tick() {

if (!this.enabled) return;

// Runs every frame for each instance with this behavior

}

```

**Saving state:**

```js

_saveToJson() { return { enabled: this.enabled, myValue: this.myValue }; }

_loadFromJson(o) { this.enabled = o.enabled ?? true; this.myValue = o.myValue ?? 0; }

```

**Bumping version:** Update `"version"` in `addon.json` — format: `major.minor.patch.build`

---

## Key Differences: Behavior vs Plugin

| | Behavior | Plugin |

|--|----------|--------|

| Attached to | Any object (per instance) | Standalone object |

| Runtime file | Single `c3runtime/main.js` | Multiple `c3runtime/*.js` files |

| Editor file | Single `editor.js` | `plugin.js` + `type.js` + `instance.js` |

| Tick access | `_tick()` built-in | Manual via events |

| Properties | Via `_getInitProperties()` | Via `SDK.PluginProperty` |

---

## Known C3 Behavior Limitations

- No direct cross-behavior communication — use instance variables or events

- `_tick()` always runs even when paused unless guarded with `if (!this.enabled) return`

- `_getInitProperties()` order must match `SetProperties([])` order in `editor.js`