-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 8 | ||
sidebar_position: 9 | ||
--- | ||
|
||
# C++ API Reference | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
sidebar_position: 8 | ||
--- | ||
|
||
# Modding and APIs | ||
|
||
## Modding | ||
|
||
The most basic way to add modding support to a game using Godot Sandbox is to add a Sandbox somewhere, and load a program into it. | ||
|
||
```py | ||
func activate(): | ||
var reader = ZIPReader.new() | ||
reader.open("res://scenes/lua/lua.zip") | ||
var buffer = reader.read_file("lua.elf") | ||
var s : Sandbox = get_node("MyVM") | ||
s.load_buffer(buffer) | ||
``` | ||
|
||
With the program loaded, the program in the Sandbox will go through an initialization phase, and could possibly perform every action that it needs to then and there. In theory, no modding API is needed and instead just a general map of the scene trees in the game is enough. | ||
|
||
## A simple modding API | ||
|
||
A modding API is there to make it easier for modders to interact with your game. Modding APIs should direct modders towards useful features and mechanisms in your game. | ||
|
||
```py | ||
var api : Dictionary | ||
api["get_player"] = func(): get_node("Player") | ||
... | ||
|
||
s.vmcall("set_api", api) | ||
``` | ||
|
||
Passing the modding API as a dictionary to a Sandbox function is quite OK as a modding API. It should be documented somewhere else. |