# Builtin types

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

Every script reaches its own node through the implicit `node` field, and other nodes through `NodeRef` fields, `Find` and `Child`. Transforms are local to the parent and read and written by value; a 2D method on a 3D node faults. See [Nodes, components and references](/language/nodes-components-and-references.md) for components and script references.

## Example

```aes run
package demo

import (
    "aego/log"
    "aego/math"
)

script Door {
    @export var OpenAngle float = 90

    var frames int

    func Ready() {
        log.Info("node " + node.Name() + ", 2D: " + string(node.Space() == 0) + ", top level: " + string(node.Parent() == nil))
        node.AddTag("Interactable.Door")
        log.Info("is interactable: " + string(node.HasTag("Interactable")))
        node.SetScale(Vec2{-1, 1})
        t := node.Transform2D()
        t.Position.X += 2
        node.SetTransform2D(t)
        log.Info("moved to " + string(node.Position().X) + ", mirrored: " + string(node.Scale().X < 0))
    }

    func Update(dt float) {
        frames++
        target := math.Deg2Rad(OpenAngle)
        node.SetRotation(math.Min(node.Rotation() + 2 * dt, target))
        if frames % 30 == 0 {
            log.Info("angle " + string(math.Round(math.Rad2Deg(node.Rotation()))) + " deg")
        }
        if frames == 100 {
            removed := node.RemoveTag("Interactable.Door")
            node.SetEnabled(false)
            log.Info("tag removed: " + string(removed) + ", enabled: " + string(node.Enabled()))
        }
    }
}
```

## NodeRef.AddTag

```
func (NodeRef) AddTag(tag string) bool
```

Adds a tag and returns false when it is malformed.

## NodeRef.Child

```
func (NodeRef) Child(name string) NodeRef
```

Returns the direct child with this name, or nil.

## NodeRef.Destroy

```
func (NodeRef) Destroy()
```

Removes the node and its children at the end of the phase.

## NodeRef.Enabled

```
func (NodeRef) Enabled() bool
```

Reports the node's own enabled flag, ignoring its parents.

## NodeRef.Find

```
func (NodeRef) Find(path string) NodeRef
```

Resolves a path relative to the node: Weapon/Gun, ../Sibling or /Root/Player.

## NodeRef.HasTag

```
func (NodeRef) HasTag(tag string) bool
```

Reports whether the node has the tag or a tag under it: Enemy matches Enemy.Flying.

## NodeRef.IsAlive

```
func (NodeRef) IsAlive() bool
```

Reports whether the node exists. It is false right after Destroy.

## NodeRef.IsPrefabInstance

```
func (NodeRef) IsPrefabInstance() bool
```

Reports whether the node is a prefab copy or lies inside one.

## NodeRef.Name

```
func (NodeRef) Name() string
```

Returns the node name, unique among its siblings.

## NodeRef.Parent

```
func (NodeRef) Parent() NodeRef
```

Returns the parent node, or nil for top-level nodes.

## NodeRef.Position

```
func (NodeRef) Position() Vec2
```

Returns the local position relative to the parent.

## NodeRef.Position3

```
func (NodeRef) Position3() Vec3
```

Returns the local 3D position.

## NodeRef.PrefabRoot

```
func (NodeRef) PrefabRoot() NodeRef
```

Returns the root of the nearest prefab copy that holds the node, the node itself for a root, or nil.

## NodeRef.RemoveTag

```
func (NodeRef) RemoveTag(tag string) bool
```

Removes a tag and returns whether the node had it.

## NodeRef.Rotation

```
func (NodeRef) Rotation() float
```

Returns the local rotation in radians, clockwise.

## NodeRef.Rotation3

```
func (NodeRef) Rotation3() Quat
```

Returns the local 3D rotation.

## NodeRef.Scale

```
func (NodeRef) Scale() Vec2
```

Returns the local scale.

## NodeRef.SetEnabled

```
func (NodeRef) SetEnabled(enabled bool)
```

Turns the node on or off. Disabled nodes and their children are not drawn.

## NodeRef.SetPosition

```
func (NodeRef) SetPosition(p Vec2)
```

Sets the local position.

## NodeRef.SetPosition3

```
func (NodeRef) SetPosition3(p Vec3)
```

Sets the local 3D position.

## NodeRef.SetRotation

```
func (NodeRef) SetRotation(radians float)
```

Sets the local rotation in radians.

## NodeRef.SetRotation3

```
func (NodeRef) SetRotation3(q Quat)
```

Sets the local 3D rotation.

## NodeRef.SetScale

```
func (NodeRef) SetScale(scale Vec2)
```

Sets the local scale. A negative X mirrors the node.

## NodeRef.SetTransform2D

```
func (NodeRef) SetTransform2D(t Transform2D)
```

Replaces the local 2D transform.

## NodeRef.SetTransform3D

```
func (NodeRef) SetTransform3D(t Transform3D)
```

Replaces the local 3D transform.

## NodeRef.Space

```
func (NodeRef) Space() int
```

Returns 0 for 2D nodes and 1 for 3D nodes.

## NodeRef.Transform2D

```
func (NodeRef) Transform2D() Transform2D
```

Returns a copy of the local 2D transform. Change it and pass it to SetTransform2D.

## NodeRef.Transform3D

```
func (NodeRef) Transform3D() Transform3D
```

Returns a copy of the local 3D transform.

## NodeRef.WorldPosition

```
func (NodeRef) WorldPosition() Vec2
```

Returns the position in world space, as of the last transform pass.
