GDExtensionSummator

This repository is for showcasing the new GDExtension system in Godot 4. The C++ code is from the Custom modules example of the Godot docs.

-> Feel free to use this repository as a template for your GDExtensions

Versioning

This repository was created with Godot v4.0.alpha.custom_build [622806397]. To build the extension succesfully, please make sure to use this or a newer version built from the master branch.

Contributing

If you can’t compile the extension, please open an issue with the error log in your terminal

Getting started / Building the extension

To compile the extension you need to follow these steps:

  1. Click on the green “Use this template” button to generate the repository for you

  2. Clone the extension recursively from this repository

# --recursive to automatically load the submodule godot-cpp
# The git adress can be found under the green "Code" dropdown menu
git clone --recursive (--GITHUB ADRESS--)
  1. Make sure you are in the top level of the repository

pwd
.../GDExtensionSummator
  1. Go inside the godot-cpp folder
cd godot-cpp
  1. Compile godot-cpp and generate bindings
scons target=debug generate_bindings=yes
  1. Go back to the top level of the directory
cd ..
  1. Compile the extension
scons target=debug

Using the extension

After compiling the extension succesfully, 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()

GitHub

View Github