Skip to content

Commit

Permalink
Add initial modding API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Sep 30, 2024
1 parent 44a8808 commit 9bddea5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/godot/cppapi.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 8
sidebar_position: 9
---

# C++ API Reference
Expand Down
34 changes: 34 additions & 0 deletions docs/godot/modding.md
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.

0 comments on commit 9bddea5

Please sign in to comment.