mirror of
https://github.com/mleem97/gregWiki.git
synced 2026-04-11 03:29:19 +02:00
update: docs to new architecture
This commit is contained in:
@@ -1,31 +1,67 @@
|
||||
---
|
||||
id: modding-language-requirement
|
||||
title: Modding language (C# only)
|
||||
title: Modding language support
|
||||
slug: /reference/modding-language-requirement
|
||||
description: Mandatory language for mods, MelonLoader plugins, and extensions — C# only.
|
||||
description: Supported languages for mods, MelonLoader plugins, and extensions — C#, Lua, and Rust/native.
|
||||
---
|
||||
|
||||
# Modding language (C# only)
|
||||
# Modding language support
|
||||
|
||||
## Requirement
|
||||
## Supported languages
|
||||
|
||||
**All logic for mods, MelonLoader plugins, and framework extensions must be implemented in C#.**
|
||||
gregCore supports **three modding languages** through its Language Bridge system:
|
||||
|
||||
That applies to anything shipped as a **`gregMod.*`**, **`gregExt.*`**, or **`FFM.Plugin.*`** / **`FMF.*`** module that loads through the MelonLoader / IL2CPP stack: gameplay code, Harmony patches, UI, networking hooks, and data handling belong in **C#** (typically targeting **.NET** compatible with your MelonLoader build).
|
||||
| Language | Runtime | Mod location | Best for |
|
||||
|----------|---------|-------------|----------|
|
||||
| **C#** | MelonLoader / .NET (direct IL2CPP interop) | `Mods/*.dll` | Plugins, deep framework extensions, performance-critical code |
|
||||
| **Lua** | MoonSharp VM in `LuaLanguageBridge` | `Mods/ScriptMods/lua/<modname>/` | Gameplay mods, UI overlays, event-driven logic, rapid prototyping |
|
||||
| **Rust / native** | `FFIBridge` (C ABI) | `Mods/RustMods/*.dll` or `.greg` | Native performance, existing Rust codebases |
|
||||
|
||||
## C# (primary)
|
||||
|
||||
All logic for MelonLoader plugins and framework extensions ships in **C#** (`.NET` compatible with MelonLoader). This is the traditional path and gives direct access to Harmony, IL2CPP interop, and all Unity APIs.
|
||||
|
||||
## Lua
|
||||
|
||||
Lua scripts run inside gregCore's **MoonSharp VM** and interact with the game through the `greg.*` API:
|
||||
|
||||
- **`greg.unity.*`** — handle-based Unity object manipulation (FindObjectsOfType, GetComponent, Instantiate, TMPro, TextMesh, Transform, Material, Physics)
|
||||
- **`greg.on()` / `greg.hook.before()` / `greg.hook.after()`** — subscribe to game events and Harmony patches
|
||||
- **`greg.gui.*`** — IMGUI drawing (OnGUI)
|
||||
- **`greg.io.*`** — file system access
|
||||
- **`greg.input.*`** — keyboard input
|
||||
- **`greg.config.*`** — key=value config files
|
||||
- **`greg.color.*`** — hex color utilities
|
||||
|
||||
Lua mods are deployed as `.lua` files under `Mods/ScriptMods/lua/`. They do not require compilation or IL2CPP assemblies. gregCore discovers and loads them automatically.
|
||||
|
||||
**Lifecycle:** Lua scripts define optional global functions `on_update(dt)`, `on_scene(name)`, and `on_gui()` that gregCore calls at the appropriate Unity lifecycle points.
|
||||
|
||||
**Example:** [FMF.HexLabelMod](/wiki/mods/fmf-hex-label-mod) is a pure Lua mod (~300 lines) that uses `greg.unity.*` and `greg.hook.*` to add hex color labels to game objects.
|
||||
|
||||
## Rust / native
|
||||
|
||||
Native mods (Rust, C, C++) are loaded by `FFIBridge` and communicate through a C ABI:
|
||||
|
||||
- `mod_info()` — returns mod metadata
|
||||
- `mod_init(api_table)` — receives a `GameAPITable` with function pointers
|
||||
- `mod_update(dt)` — called per frame
|
||||
- `mod_on_scene_loaded(name)` — scene transitions
|
||||
- `mod_on_event(id, data, size)` — game events (numeric `EventIds`)
|
||||
- `mod_shutdown()` — cleanup
|
||||
|
||||
The `RustLanguageBridgeAdapter` fully delegates lifecycle calls to `FFIBridge`, including hot-reload support for non-DLL formats (`.greg`, `.gregr`).
|
||||
|
||||
## Rationale
|
||||
|
||||
- **MelonLoader** loads managed **.NET** assemblies; Harmony and the interop layer are built around C#.
|
||||
- A single language keeps reviews, debugging, and CI consistent for contributors.
|
||||
|
||||
## What this does *not* restrict
|
||||
|
||||
- **Framework core** (`gregCore`) may still ship **native** loading paths maintained by core maintainers (Rust/other natives als **vorkompilierte** `.dll`/`.greg`/…-Module, geladen über **`FFIBridge`** in `gregCore/framework/src/ModLoader/`), plus build scripts and tooling. Those are **not** substitutes for implementing mod/plugin/extension **logic** outside C#.
|
||||
- **Documentation**, **config** (JSON/YAML), and **assets** are not “logic” in this sense.
|
||||
- **gregStore**, **gregWiki**, and other non–in-game stacks may use other languages as appropriate.
|
||||
- **C#** remains the primary language because MelonLoader, Harmony, and IL2CPP interop are built around it.
|
||||
- **Lua** lowers the barrier for mod authors who don't want to set up a C# build chain. The `greg.*` API handles all Il2Cpp bridging safely.
|
||||
- **Rust/native** serves performance-critical use cases and mods already written in Rust.
|
||||
- A single framework (`gregCore`) manages all three runtimes, keeping reviews, debugging, and CI consistent.
|
||||
|
||||
## See also
|
||||
|
||||
- [System architecture & documentation principles](/wiki/meta/system-architecture-principles) — stack model and documentation rules
|
||||
- [Repository architecture](/wiki/framework/architecture) — language bridges and handle system
|
||||
- [Greg hooks & events](/wiki/framework/greg-hooks-and-events) — Lua event subscriptions
|
||||
- [System architecture & documentation principles](/wiki/meta/system-architecture-principles) — stack model
|
||||
- [Framework](/wiki/mods/framework) — runtime surface for mod authors
|
||||
- [FMF hook naming](/wiki/reference/fmf-hook-naming)
|
||||
|
||||
Reference in New Issue
Block a user