Logo Gdscript Patterns

Gdscript Patterns

Tổ chức
SummerEngine
gdscript-patterns

GDScript conventions: type hints, signals, exports, onready, lifecycle methods, node paths, naming.

Tổng quan

Nhà phát hànhSummerEngine
Kho mãsummer
Tên kỹ nănggdscript-patterns
Sao
91
Bản fork
8
Tệp đi kèm
2
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 2 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được SummerEngine công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Gdscript Patterns trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/SummerEngine/summer/tree/main/library/skills/gdscript-patterns
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/SummerEngine/summer.git /tmp/summer
mkdir -p .claude/skills
cp -r /tmp/summer/library/skills/gdscript-patterns .claude/skills/gdscript-patterns
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Gdscript Patterns trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Gdscript Patterns ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Gdscript Patterns không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

GDScript Patterns for Summer Engine

When writing GDScript for Summer Engine projects, follow these patterns. They match the engine's GDScript 4 conventions and work well with MCP scene operations.

Type Hints

Always use type hints for clarity and editor support:

gdscript
var health: int = 100
var speed: float = 5.0
var player_name: String = ""
var velocity: Vector3 = Vector3.ZERO
var is_alive: bool = true

For nodes, use typed references:

gdscript
@onready var collision_shape: CollisionShape3D = $CollisionShape3D
@onready var camera: Camera3D = $Camera3D

Signals

Define signals at the top of the script, then emit them:

gdscript
signal died
signal health_changed(new_health: int)
signal item_collected(item_name: String)

func take_damage(amount: int) -> void:
    health -= amount
    health_changed.emit(health)
    if health <= 0:
        died.emit()

When connecting via MCP, use summer_connect_signal with the emitter path, signal name, receiver path, and method name. The receiver script must have the method defined.

Exports

Use @export for inspector-editable properties:

gdscript
@export var move_speed: float = 5.0
@export var jump_force: float = 10.0
@export var max_health: int = 100
@export var can_double_jump: bool = false

Exports appear in the inspector. MCP can set initial values via summer_set_prop after the node exists, but exports are best for values the designer tweaks.

Lifecycle Methods

MethodWhen it runsUse for
_ready()Once when node enters treeInitialization, getting node references
_process(delta: float)Every frameUI, non-physics logic
_physics_process(delta: float)Every physics frame (fixed)Movement, physics, collision

For character movement, use _physics_process and move_and_slide().

Node Access

gdscript
# Prefer $ for direct children
var camera = $Camera3D

# get_node() for dynamic paths
var target = get_node("../Enemy/HealthBar")

# get_parent() / get_children() when needed
var siblings = get_parent().get_children()

Common Patterns

For health systems, input handling, and state machines, see reference.md.

Anti-patterns — introspection traps

The engine's introspection API has Object-instance methods that look like they should work on script-class references. They don't. Calling them on a const ScriptName = preload(...) reference is a parse error, not a runtime no-op.

WrongRightWhy
if SomeScript.has_static_method("play"): SomeScript.play(...)Just call SomeScript.play(...) directly. If the method exists in the script, it parses; if not, the parser catches it.has_static_method() is an Object instance method. SomeScript here is a Script reference. It has no has_static_method member, so the parser rejects the call.
if SomeScript.has_method("foo") (on a script-class ref)Same. Call foo() directly, or check is_instance_of() after instancing.Same trap.
Defensive guards "in case the script ships in parallel"Don't ship in parallel agents that depend on each other's APIs without one of them landing first. The compiler will catch missing methods at parse time.Guards that don't compile aren't guards.

Rule of thumb: if you're tempted to write Klass.has_*("name") on a const Klass = preload(...) reference, you're confusing class-level introspection (compile-time, automatic) with instance-level introspection (Object method, runtime). GDScript's parser already does the compile-time check for free.

Side note on has_method vs has_static_method: has_method works on a node/instance to check if the instance has a method. has_static_method works on an Object instance to check if its class has a static method. Neither is callable on a bare Script reference (preload(...) result). To check static-method presence at runtime, call the method inside a try-equivalent. In practice if your code paths are well-typed you don't need to.

Anti-pattern — @onready var = $Path on nodes that don't exist on every variant

The engine resolves $Path (the get_node shorthand) at @implicit_ready time. If the node is missing from the current scene, you get Node not found: "X" (relative to "Y") errors before any of your _ready() runtime guards can run.

Common case: a script is shared by multiple scene variants where some variants have an optional child. Even if every code path that touches the variable has a if inventory_ui: guard, the @onready line itself errors at scene load.

WrongRight
@onready var inventory_ui: CanvasLayer = $InventoryUI@onready var inventory_ui: CanvasLayer = get_node_or_null("InventoryUI")
@onready var hp_bar: ProgressBar = $HUD/HPBar (HUD optional)@onready var hp_bar: ProgressBar = get_node_or_null("HUD/HPBar")

Rule of thumb: if the node is required for the script to function at all, use $Path and rely on the parse-time error. If the node may be missing in some scene variants the script is reused across, use get_node_or_null and guard at every read site.

Anti-pattern — Label3D.label_settings (it doesn't exist)

LabelSettings is a resource type used by Label (the 2D Control node) to bundle font + size + outline + colors. Label3D does NOT accept it. Assigning LabelSettings to label_settings on a Label3D raises Invalid assignment of property or key 'label_settings' with value of type 'LabelSettings' on a base object of type 'Label3D'.

Label3D exposes the same styling fields as direct properties:

gdscript
# WRONG - parses but errors at runtime when label is a Label3D.
var settings := LabelSettings.new()
settings.font = my_font
settings.font_size = 24
settings.outline_size = 2
settings.outline_color = my_outline
my_label_3d.label_settings = settings  # <-- runtime error

# RIGHT - set the styling directly on the Label3D.
my_label_3d.font = my_font
my_label_3d.font_size = 24
my_label_3d.outline_size = 2
my_label_3d.outline_modulate = my_outline

Note the field name difference too: LabelSettings.outline_color (Label 2D) vs Label3D.outline_modulate (Label3D). Easy to miss in copy-paste.

Rule of thumb: LabelSettings is for Label only. For Label3D use direct properties. For RichTextLabel, neither — it has its own theme overrides.

Scene Integration

When the AI adds a node with Summer MCP tools and attaches a script, the script path is set via summer_set_prop(path, "script", "res://path/to/script.gd"). The script file must exist first. Create it with guarded summer_write_file or edit it with summer_replace_text, then attach the script and connect scene signals.

For signal connections, the receiver must have the handler method. Create the script with the method stub before calling summer_connect_signal.

From a shell

No Summer MCP tools in this session? Run each one as a command; when summer --version is missing or below 4.0, use npx -y summer-engine@latest in place of summer. Fields are flags in kebab-case (--scene-path res://main.tscn) or one --input '<json>', and summer ops describe <op> prints the exact input. The summer-cli skill has the rest.

In this skillCommand
summer_connect_signalsummer engine connect-signal
summer_get_script_errorssummer engine get-script-errors
summer_input_map_bindsummer engine input-map-bind
summer_replace_textsummer engine replace-text
summer_set_propsummer engine set-prop
summer_write_filesummer engine write-file

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Gdscript Patterns làm được gì?

GDScript conventions: type hints, signals, exports, onready, lifecycle methods, node paths, naming.

Vì sao nên dùng Gdscript Patterns trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Gdscript Patterns là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Gdscript Patterns trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/SummerEngine/summer/tree/main/library/skills/gdscript-patterns. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Gdscript Patterns?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Gdscript Patterns với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Gdscript Patterns với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Gdscript Patterns có miễn phí không?

Có. Kỹ năng này được SummerEngine phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇