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:
@@ -4,9 +4,21 @@ sidebar_label: Repository architecture
|
||||
description: Current multi-repo layout with `gregFramework` as a local wrapper and clear repository boundaries.
|
||||
---
|
||||
|
||||
## Modding language
|
||||
## Modding languages
|
||||
|
||||
Mods, MelonLoader plugins, and extensions ship their **logic in C# only** (MelonLoader / .NET). Scope vs framework core (e.g. Rust bridge): [Modding language (C# only)](/wiki/reference/modding-language-requirement).
|
||||
gregCore supports **three modding languages** through its Language Bridge system:
|
||||
|
||||
| Language | Bridge | Runtime | Mod format |
|
||||
|----------|--------|---------|------------|
|
||||
| **C#** | MelonLoader / .NET | Direct IL2CPP interop | `.dll` assemblies in `Mods/` |
|
||||
| **Lua** | `LuaLanguageBridge` (MoonSharp VM) | `greg.*` API with handle-based Unity access | `.lua` scripts in `Mods/ScriptMods/lua/` |
|
||||
| **Rust / native** | `RustLanguageBridgeAdapter` → `FFIBridge` | C ABI exports (`mod_init`, `mod_update`, `mod_on_event`) | `.dll`/`.greg` in `Mods/RustMods/` |
|
||||
|
||||
**Lua scripts** interact with the game exclusively through the `greg.*` API surface — a set of C#-backed modules that expose Unity/IL2CPP operations via integer handles. This includes `greg.unity.*` (object manipulation), `greg.on()`/`greg.hook.*` (event and Harmony patch subscriptions), `greg.gui.*` (IMGUI), `greg.io.*` (file system), and `greg.input.*` (keyboard). See [Greg hooks & events](/wiki/framework/greg-hooks-and-events) for the event API and the [Language Bridges README](https://github.com/mleem97/gregFramework/blob/main/gregCore/framework/ModLoader/LanguageBridges/README.md) for the full Lua API reference.
|
||||
|
||||
**Rust/native mods** receive a `GameAPITable` function-pointer table on `mod_init` and numeric `EventIds` via `mod_on_event`. The `FFIBridge` handles shadow-copying, lifecycle dispatch, and hot-reload.
|
||||
|
||||
Policy details: [Modding language support](/wiki/reference/modding-language-requirement).
|
||||
|
||||
## Target runtime layers
|
||||
|
||||
@@ -25,7 +37,8 @@ Above the raw repositories, the **logical** model is **ModManager → Framework
|
||||
| ------ | ------ |
|
||||
| **Wrapper** | `gregFramework/` holds local checkouts of individual repositories. |
|
||||
| **Core** | `gregCore/` — **framework core**: translation, hooks, Harmony/event runtime, MCP, templates, and related core features. |
|
||||
| **Rust / native FFI** | Loads native mod exports inside the **framework** assembly: `gregCore/framework/src/ModLoader/FfiBridge.cs`; Melon host remains **`DataCenterModLoader.Core`** in `Core.cs` (Melon display name **RustBridge**). |
|
||||
| **Language Bridges** | `gregCore/framework/ModLoader/LanguageBridges/` — Lua (MoonSharp), TypeScript/JS (planned), Rust/native (`FFIBridge`). Lua modules under `LuaModules/` provide the `greg.*` API. |
|
||||
| **Rust / native FFI** | Loads native mod exports: `gregCore/framework/ModLoader/FfiBridge.cs`; adapter: `RustLanguageBridgeAdapter.cs`. Full lifecycle: init, update, scene load, event dispatch, shutdown. |
|
||||
| **Mods** | `gregMod.<Name>/` — one repo each, directly under `gregFramework/`. |
|
||||
| **Extensions** | `gregExt.<Name>/` — one repo each, directly under `gregFramework/`. |
|
||||
| **Docs** | `gregWiki/` — documentation site repository. |
|
||||
@@ -43,3 +56,7 @@ Hook naming and the registry are owned by core; when repos split, **core** remai
|
||||
## Steam & Workshop
|
||||
|
||||
Workshop templates and deployment scripts live in the core repo under `gregCore/Templates/` and `gregCore/scripts/`.
|
||||
|
||||
## Lua handle system
|
||||
|
||||
Lua cannot hold direct references to Il2Cpp objects. gregCore uses an **integer handle registry** (`LuaObjectHandleRegistry`) that maps `int` handles to live .NET objects via weak references. Lua scripts receive handles from `greg.unity.find()`, `greg.unity.get_component()`, etc. and pass them back to `greg.unity.*` functions. Handles are automatically pruned when the underlying Unity objects are destroyed.
|
||||
|
||||
@@ -37,9 +37,42 @@ Build stable hook strings with **`GregHookName.Create(GregDomain.*, "Action")`**
|
||||
- **Mapping → `greg.*`:** **`GregNativeEventHooks`** (`gregCore/framework/src/Sdk/GregNativeEventHooks.cs`); emission via **`GregHookIntegration`** in the same ModLoader tree.
|
||||
- **Wiki table:** [greg hooks catalog](/wiki/reference/greg-hooks-catalog) (generator: `gregCore/tools/Generate-GregHookCatalog.ps1`).
|
||||
|
||||
## Lua event & hook subscriptions
|
||||
|
||||
Lua scripts subscribe to the same event surfaces through the `greg.*` API injected by `GregHooksLuaModule`:
|
||||
|
||||
| Lua API | C# backend | Purpose |
|
||||
|---------|-----------|---------|
|
||||
| `greg.on(hookName, fn)` | `GregEventDispatcher.On()` | Subscribe to any `greg.*` event — receives payload as Lua table |
|
||||
| `greg.off(hookName)` | `GregEventDispatcher.Off()` | Unsubscribe all Lua handlers for a hook |
|
||||
| `greg.emit(hookName, payload)` | `GregEventDispatcher.Emit()` | Emit a custom event (other Lua/C# listeners receive it) |
|
||||
| `greg.hook.before(hookName, fn)` | `HookBinder.OnBefore()` | Harmony **prefix** — fn receives `{hook_name, type_name, method_name, instance_handle, arg_count}` |
|
||||
| `greg.hook.after(hookName, fn)` | `HookBinder.OnAfter()` | Harmony **postfix** — same context table |
|
||||
| `greg.hook.off(hookName)` | `HookBinder.Unregister()` | Remove all handlers for a Harmony hook |
|
||||
|
||||
**Example** — react to CableSpinner.Start in Lua:
|
||||
|
||||
```lua
|
||||
greg.hook.after("greg.Misc.OnStart", function(ctx)
|
||||
if ctx.type_name and ctx.type_name:find("CableSpinner") then
|
||||
greg.log("new spinner spawned, handle: " .. tostring(ctx.instance_handle))
|
||||
end
|
||||
end)
|
||||
```
|
||||
|
||||
**Example** — listen to game events:
|
||||
|
||||
```lua
|
||||
greg.on("greg.PLAYER.CoinChanged", function(payload)
|
||||
greg.log("coins changed by " .. tostring(payload.coinChangeAmount))
|
||||
end)
|
||||
```
|
||||
|
||||
All hook names from `GregNativeEventHooks` (e.g. `greg.PLAYER.CoinChanged`, `greg.SERVER.PowerButton`) and `HookBinder` aliases (e.g. `greg.Misc.OnStart`) are available to Lua.
|
||||
|
||||
## Rust FFI
|
||||
|
||||
Rust/native mods receive **numeric** event ids; C# mirrors the same moments as **`greg.*`** through **`GregHookIntegration`** while the game runs (including when the FFI connection is down for the managed **`greg.*` surface). Bridge code: **`FfiBridge` / `FFIBridge`** under `framework/src/ModLoader/`.
|
||||
Rust/native mods receive **numeric** event ids; C# mirrors the same moments as **`greg.*`** through **`GregHookIntegration`** while the game runs. The `RustLanguageBridgeAdapter` fully delegates all lifecycle calls (`OnUpdate`, `OnSceneLoaded`, `Shutdown`, event dispatch) to `FFIBridge`. Bridge code: **`FfiBridge.cs`** / **`RustLanguageBridgeAdapter.cs`** under `framework/ModLoader/`.
|
||||
|
||||
## MelonLoader entry points (one DLL)
|
||||
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
---
|
||||
title: HexMod
|
||||
sidebar_label: HexMod
|
||||
description: Hex label mod — in-world hex color labels for cable spinners and racks.
|
||||
description: Hex label mod — in-world hex color labels for cable spinners and racks, now powered by Lua.
|
||||
---
|
||||
|
||||
# HexMod
|
||||
|
||||
The **Hex Label** mod adds in-world hex color labels for cable spinners and racks.
|
||||
|
||||
Since **v00.02**, HexLabel is a **pure Lua mod** powered by gregCore's Lua runtime. All mod logic lives in `lua/hexlabel/main.lua`; the C# assembly is a thin metadata-only bootstrap.
|
||||
|
||||
## Steamworks Info
|
||||
|
||||
| Field | Value |
|
||||
|-------|-------|
|
||||
| **Assembly** | `FMF.HexLabelMod.dll` |
|
||||
| **Version** | `00.01.0009` |
|
||||
| **Assembly** | `FMF.HexLabelMod.dll` (bootstrap only) |
|
||||
| **Lua script** | `Mods/ScriptMods/lua/hexlabel/main.lua` |
|
||||
| **Version** | `00.02.0000` |
|
||||
| **Author** | mleem97 |
|
||||
| **Game** | Data Center (App 4170200) |
|
||||
| **Workshop Tags** | `modded`, `melonloader`, `mod` |
|
||||
@@ -21,11 +24,19 @@ The **Hex Label** mod adds in-world hex color labels for cable spinners and rack
|
||||
## Downloads
|
||||
|
||||
- **Steam Workshop:** [FMF.HexLabelMod — workshop item](https://steamcommunity.com/sharedfiles/filedetails/?id=3701404621) (subscribe in-game or via GregModManager)
|
||||
- **GitHub:** [Latest release](https://github.com/mleem97/gregModHexLabelMod/releases/latest) (`FMF.HexLabelMod.dll`)
|
||||
- **Manual:** Drop `FMF.HexLabelMod.dll` into `<Data Center>/Mods/`
|
||||
- **GitHub:** [Latest release](https://github.com/mleem97/gregModHexLabelMod/releases/latest)
|
||||
- **Manual:** Copy `lua/hexlabel/` to `Mods/ScriptMods/lua/hexlabel/`
|
||||
|
||||
## Architecture
|
||||
|
||||
| Component | Location | Role |
|
||||
|-----------|----------|------|
|
||||
| **Lua script** | `lua/hexlabel/main.lua` | All mod logic: labeling, HUD, hex viewer, config |
|
||||
| **C# bootstrap** | `Main.cs` → `FMF.HexLabelMod.dll` | MelonLoader metadata only |
|
||||
| **gregCore APIs** | `greg.unity.*`, `greg.hook.*`, `greg.gui.*`, `greg.io.*`, `greg.input.*` | Generic framework services used by the Lua script |
|
||||
|
||||
## Source & layout
|
||||
|
||||
- **Repository:** [`mleem97/gregModHexLabelMod`](https://github.com/mleem97/gregModHexLabelMod) (assembly `FMF.HexLabelMod.dll`)
|
||||
- **Repository:** [`mleem97/gregModHexLabelMod`](https://github.com/mleem97/gregModHexLabelMod)
|
||||
|
||||
See also the detailed wiki article [FMF.HexLabelMod](/wiki/mods/fmf-hex-label-mod).
|
||||
|
||||
Reference in New Issue
Block a user