Index of every page on this site: llms.txt
All skills
jame581 avatar

/gdscript-advanced

@426e8ab
by Jan Mesarčjame581/godotprompter979 stars
63
Run it yourself

Use when writing production-grade GDScript — performance idioms, metaprogramming, @tool lifecycle, async pitfalls, and signal/Callable trade-offs

Use this Skill: https://skilld.dev/gh/jame581/godotprompter/gdscript-advanced

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesprofiler-recipes.md

≈625 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Profiler-Driven Optimization Recipes

Reference for skills/gdscript-advanced/SKILL.md — annotated before/after examples for common profiler hot spots.

← Back to SKILL.md


1. String allocation in _process

Hot:

func _process(delta: float) -> void:
    label.text = "Score: %d / %d" % [score, max_score]

This allocates a new String every frame even if the values haven't changed.

Cool:

var _last_score: int = -1

func _process(delta: float) -> void:
    if score != _last_score:
        label.text = "Score: %d / %d" % [score, max_score]
        _last_score = score

Or, even better — drive the label from a signal:

# In ScoreManager
signal score_changed(new_score: int)

# In UI
score_manager.score_changed.connect(_on_score_changed)
func _on_score_changed(new: int) -> void:
    label.text = "Score: %d / %d" % [new, max_score]

2. Repeated get_node calls

Hot:

func _process(delta: float) -> void:
    $UI/HUD/HealthBar.value = health
    $UI/HUD/StaminaBar.value = stamina
    $UI/HUD/ManaBar.value = mana

Cool:

@onready var _health_bar: ProgressBar = $UI/HUD/HealthBar
@onready var _stamina_bar: ProgressBar = $UI/HUD/StaminaBar
@onready var _mana_bar: ProgressBar = $UI/HUD/ManaBar

func _process(delta: float) -> void:
    _health_bar.value = health
    _stamina_bar.value = stamina
    _mana_bar.value = mana

3. Position-update signal storms

Hot: emitting position_changed every physics frame for a non-player entity.

Cool: emit at 10 Hz only when the listener actually needs it; for distance checks, poll directly.

var _emit_timer: float = 0.0
const EMIT_INTERVAL: float = 0.1  # 10 Hz

func _physics_process(delta: float) -> void:
    _emit_timer += delta
    if _emit_timer >= EMIT_INTERVAL:
        _emit_timer = 0.0
        position_changed.emit(global_position)

4. Allocator churn

Hot:

func _process(delta: float) -> void:
    var nearby: Array = _find_enemies_within(10.0)  # allocates a new Array every frame
    for enemy in nearby:
        enemy.take_damage(damage_per_second * delta)

Cool: pool the array as a member:

var _nearby_buffer: Array = []

func _process(delta: float) -> void:
    _nearby_buffer.clear()
    _find_enemies_within_into(10.0, _nearby_buffer)
    for enemy in _nearby_buffer:
        enemy.take_damage(damage_per_second * delta)

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts7d3 checks · Risk SAFE
  • Gen Agent Trust Hub7d

    The skill is a set of technical guidelines for advanced Godot Engine development. It contains no malicious code, external dependencies, or security risks. In fact, it explicitly teaches security best practices, such as allowlisting method names when using dynamic dispatch to prevent potential exploits in game modding or networking.

  • Socket7d

    No alerts

  • Snyk7d

    Risk: LOW · No issues

Signed by skilld at 426e8ab. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 6 days ago.

Activeupdated last week

README badge

README badge for jame581/godotprompter/gdscript-advanced