Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/libriscv/godot-sandbox

Sandboxing that enables safe modding for Godot games
https://github.com/libriscv/godot-sandbox

cpp godot godot4 modding rust sandbox scripting

Last synced: 2 months ago
JSON representation

Sandboxing that enables safe modding for Godot games

Awesome Lists containing this project

README

        





Godot Sandbox Build



Website | Code Examples | Discord | Web Demo

-----


Safe, low-latency and fast sandbox
for the Godot game engine.

-----

This extension exists to allow Godot creators to implement safe modding support, such that they can pass around programs built by other players, knowing that these programs cannot harm other players. All Godot platforms are supported.

## Installation

- Automatic (Recommended): Download the plugin from the official [Godot Asset Store](.) using the **AssetLib** tab in Godot by searching for **Godot Sandbox**.

- Manual: Download the [latest github release](https://github.com/libriscv/godot-sandbox/releases/latest) and move only the **addons** folder into your project **addons** folder.

### What can I do?

- You can implement a modding API for your game, to be used inside the sandbox. This API can then be used by other players to extend your game, in a safe manner. That is, they can send their mod to other people, including you, and they (and you) can assume that it is safe to try out the mod. The mod is *not supposed* to be able to do any harm. That is the whole point of this extension.
- You can implement support for your favorite language inside the sandbox. The sandbox receives Variants from Godot or GDScript, and can respond back with Variants. This means the communication is fully dynamic, and supports normal Godot usage.
- You can distribute programs from a server to clients on login. The programs will behave the same way on all platforms, including 32-bit platforms. You can use this to live-distribute changes, like bugfixes, to the game without having to redeploy the game itself.

## Usage

- Write C++ or Rust in the Godot editor. An accompanying ELF resource is created.

- Create a new `Sandbox` and [assign the ELF resource to it](https://libriscv.no/docs/godot/sandbox/#create-a-sandbox)
- Access to the underlying Sandbox
- Lifetime as any other node
- Auto-completion from other GDScripts using @export

- Or, [directly assign an ELF script resource to a node](https://libriscv.no/docs/godot/sandbox/#using-programs-directly-as-scripts)
- Shared sandbox among all instances with that script
- Maximum scalability
- Call functions and attach signals like GDScript

```C++
static void add_coin(const Node& player) {
static int coins = 0;
coins ++;
Node coinlabel = player.get_parent().get_node("Texts/CoinLabel");
coinlabel.set("text", "You have collected "
+ std::to_string(coins) + ((coins == 1) ? " coin" : " coins"));
}

extern "C" Variant _on_body_entered(Variant arg) {
Node player_node = arg.as_node();
if (player_node.get_name() != "Player") {
return {};
}
Node(".").queue_free(); // Remove the current coin!
add_coin(player_node);
return {};
}
```

Script of a simple Coin pickup, with a counter that updates a label in the tree of the player. This script can be attached to the Coin just like GDScript.

You may also have a look at our [demo repository](https://github.com/libriscv/godot-sandbox-demo) for the Godot Sandbox. It's a tiny platformer that uses C++ and Rust.

## Contributing

Requirements:
- [SCons](https://www.scons.org)
- [python3](https://www.python.org)

If you want to contribute to this repo, here are steps on how to build locally:

```sh
scons
```

Linting:

```sh
./scripts/clang-tidy.sh
```