3.6 KiB
id, title, slug, description
| id | title | slug | description |
|---|---|---|---|
| modding-language-requirement | Modding language support | /reference/modding-language-requirement | Supported languages for mods, MelonLoader plugins, and extensions — C#, Lua, and Rust/native. |
Modding language support
Supported languages
gregCore supports three modding languages through its Language Bridge system:
| 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 patchesgreg.gui.*— IMGUI drawing (OnGUI)greg.io.*— file system accessgreg.input.*— keyboard inputgreg.config.*— key=value config filesgreg.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 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 metadatamod_init(api_table)— receives aGameAPITablewith function pointersmod_update(dt)— called per framemod_on_scene_loaded(name)— scene transitionsmod_on_event(id, data, size)— game events (numericEventIds)mod_shutdown()— cleanup
The RustLanguageBridgeAdapter fully delegates lifecycle calls to FFIBridge, including hot-reload support for non-DLL formats (.greg, .gregr).
Rationale
- 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
- Repository architecture — language bridges and handle system
- Greg hooks & events — Lua event subscriptions
- System architecture & documentation principles — stack model
- Framework — runtime surface for mod authors