---
generated_by: gdlink-build
generated_at: 2026-06-23T12:34:28Z
do_not_edit: true
title: GDScript
brick_type: gate
tier: Pro
generated: true
---
# GDScript
**Category:** Gate
**Tier:** Pro
## Purpose
Executes custom GDScript code to make complex decisions that can't be easily expressed with logic gates or expressions.
## Visual Reference
```{raw} html
```
## When To Use
**1. Complex AI State Machine**
```
Always Listener
-> GDScript Gate (Script: "ai_brain.gd", Function: "decide_action")
-> Animation Executor (Play: animation from Local Variable "ai_action")
```
AI brain script returns TRUE and sets "ai_action" variable, which drives animation.
**2. Custom Scoring System**
```
Collision Listener (Group: "targets")
-> GDScript Gate (Inline: "return calculate_score() > 100")
-> PRINT Executor ("Victory!")
```
Custom scoring logic too complex for Expression Gate.
**3. Pathfinding Decision**
```
Near Listener (Distance: 20.0, Expose Data: true)
-> GDScript Gate (Script: "pathfinding.gd", Function: "has_clear_path")
-> Motion Executor (Move toward target)
```
Checks if path to target is clear using A* or NavMesh.
**4. Procedural Animation Blending**
```
Keyboard Listener (Any key)
-> GDScript Gate (Script: "animation_blend.gd")
-> Animation Executor (Controlled by script)
```
Script calculates animation blend weights based on movement speed, direction, etc.
**5. Inventory Logic**
```
Keyboard Listener (Key: "E")
-> Near Listener (Group: "items")
-> GDScript Gate (Script: "inventory.gd", Function: "can_pickup")
-> Property Executor (Add to inventory)
```
Script checks inventory space, item type, player level, etc.
```{raw} html
```
## Properties
| Property | Type | Default | Notes |
|---|---|---|---|
| Mode | option | Script Path | Script Path: Load external .gd file \| Inline Code: Write code directly |
| Script Path | string | | Path to .gd file (e.g., res://scripts/ai_logic.gd) |
| Function Name | string | evaluate | Function to call - must return bool |
| Inline Code | text | return True | GDScript code to execute (return bool) |
| Pass Context | bool | True | Pass brick context (listeners, globals, locals) to function |
| Debug Output | bool | False | Print function return value to console |