# aego/anim

> Aego 0.12.5 · development; docs build `4a32b816933e02930662f6a443cb25abe6050d090c55e237cbff5c44ae9b25f8`. [Build manifest](/docs-build.json).

An animation clip reaches an event, and the scripts on the player's node get `OnAnimEvent(id int, payload float)`. Events are declared by name in Project Settings → Animation; `anim.EventName` and `anim.EventID` turn ids into names and back. An unknown id has the name `""`, an unknown name the id `-1`. See [Animation](/animation.md).

## Example

```aes run
package demo

import (
	"aego/anim"
	"aego/log"
)

script Listener {
	var hit int

	func Ready() {
		hit = anim.EventID("Hit")
		log.Info("Hit has the id " + string(hit) + ", id 0 is called '" + anim.EventName(0) + "'")
	}

	func OnAnimEvent(id int, payload float) {
		if id == hit {
			log.Info("hit for " + string(payload))
		}
	}
}
```

## EventID

```
func EventID(name string) int
```

Returns the id of an event declared in Project Settings → Animation, or -1.

## EventName

```
func EventName(id int) string
```

Returns the name of an animation event, or an empty string for an unknown id.

## ParamIndex

```
func ParamIndex(controller AssetRef<animctrl>, name string) int
```

Returns the index of a parameter of a controller, or -1.

## StateName

```
func StateName(controller AssetRef<animctrl>, index int) string
```

Returns the name of a state of a controller, or an empty string.
