GDExtensionSummator
The Summator Example from Custom Modules made with the GDExtension system in Godot 4
Install / Use
/learn @paddy-exe/GDExtensionSummatorREADME
GDExtension-Summator
This repository is for showcasing the new GDExtension system that was introduced in Godot 4. The C++ code is from the Custom modules example of the Godot docs.
The officially maintained template can be accessed here: godot-cpp-template
:tada: Using the extension
After compiling the extension successfully, you can now use the Summator Class inside Godot
func _ready() -> void:
var s = Summator.new()
s.add(10)
s.add(20)
s.add(30)
print(s.get_total())
# outputs 60 in the console
s.reset()
🔢 Versioning
This repository is not being updated regularly anymore. It should still work in the newest versions of Godot though.
The releases are structured as GODOT_VERSION-EXTENSION_VERSION to clarify which version to use for which Godot version.
❓ What? How? Why?
If you are not sure what each file in this project does or if you want to know in detail: I wrote a blog post about the purpose of each file on my Ko-Fi page.
Alternative templates
The official template for GDExtensions is available here: godot-cpp-template. It is well-maintained and was created on the basis of this project here (I am the maintainer of the official template as well) with github action support and a better structured SCons file.
If you want to work with the latest master and godot-cpp version, check out this GDExtension template by Nathan Franke. If you are more used to CMake than Scons you can use this template here by asmalone
⚙️ Building the extension
VSCode Compilation (only applicable if you are using VSCode as your code editor)
For the initial build you can run the vscode task initial-build-extension. This compiles both godot-cpp and the extension. For all subsequent builds, you only need to run the task build-extension.
Debugging via VSCode
To debug your extension you can run the build-extension [dev build] command. To use this command you need to also modify your specific Godot paths inside the .vscode/tasks.json file. For further information see here.
Manual Compilation
To compile the extension you need to follow these steps:
-
Click on the green "Use this template" button to generate the repository for you
-
Clone the extension recursively from this repository
# The git adress can be found under the green "Code" dropdown menu
git clone (--GITHUB ADRESS--) # --recursive to automatically load the submodule godot-cpp
- Make sure you are on the right commit of the godot-cpp repository
git status # this show's you the commit. Make sure that it has the correct commit for the release you are targeting
To make sure you have the right commit, here the link to the pinned updated issue with the commit hashes
- Make sure you are in the top level of the repository so
pwdreturns the following
pwd
.../GDExtensionSummator
- Go inside the godot-cpp folder
cd godot-cpp
- Compile godot-cpp and generate the bindings (only needed once when starting development or when there is an update of the submodule)
scons # this will use the default values such as target=template_debug
- Go back to the top level of the directory
cd ..
- Compile the extension
scons # this will use the default values such as target=template_debug
Related Skills
node-connect
354.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
