mirror of
https://github.com/mleem97/gregWiki.git
synced 2026-04-11 03:29:19 +02:00
5.9 KiB
5.9 KiB
title, sidebar_label
| title | sidebar_label |
|---|---|
| FMF.HexLabelMod | FMF.HexLabelMod |
gregModHexLabelMod — pure Lua mod powered by gregCore
Release
| Channel | Link |
|---|---|
| Steam Workshop | Subscribe (item 3701404621) |
| GitHub | Releases |
Purpose
Overlays the hex color code (#RRGGBB) of each CableSpinner and Rack directly in-world in Data Center, so you can identify cable and rack colors at a glance. Includes an IMGUI HUD (top-right) with crosshair-aimed color detection and a full hex viewer (F2).
Architecture (v00.02+)
Since v00.02, HexLabel is a pure Lua mod. The C# assembly (FMF.HexLabelMod.dll) is a thin MelonLoader bootstrap that provides metadata only. All mod logic lives in lua/hexlabel/main.lua and uses the greg.* API provided by gregCore's Lua runtime.
gregCore APIs used
| API | Purpose |
|---|---|
greg.unity.find("CableSpinner") |
Find all spinner objects in scene |
greg.unity.find("Rack") |
Find all rack objects in scene |
greg.unity.get_string(h, "rgbColor") |
Read spinner color property |
greg.unity.material_hex(h, "_BaseColor") |
Read material hex color |
greg.unity.instantiate(h, parent) |
Clone source TMPro label for spinner |
greg.unity.tmpro_set(...) |
Configure cloned TMPro label text/size/color |
greg.unity.create_gameobject(name, parent) |
Create rack label container |
greg.unity.add_component(h, "TextMesh") |
Add world-space TextMesh to rack |
greg.unity.textmesh_set(...) |
Configure rack label |
greg.unity.raycast(...) / camera_ray() |
HUD crosshair aim detection |
greg.unity.get_parent_component(h, type) |
Resolve aimed object type |
greg.hook.after(hookName, fn) |
Hook CableSpinner.Start for instant labeling |
greg.config.load(path) |
Load hexposition.cfg |
greg.input.key_pressed("F2") |
Toggle hex viewer |
greg.gui.* |
IMGUI HUD and viewer window |
greg.io.read_head(path, n) |
Steam log scanning for startup gating |
Project structure
gregMod.HexLabelMod/
├── lua/hexlabel/main.lua ← All mod logic (pure Lua, ~300 lines)
├── Main.cs ← Thin C# bootstrap (metadata only)
├── FMF.HexLabelMod.csproj ← Build config
└── README.md
Requirements
| Dependency | Notes |
|---|---|
| MelonLoader | With generated IL2CPP assemblies |
| gregCore | Provides Lua runtime and greg.* API |
Installation
- Ensure gregCore is installed and up to date.
- Copy
lua/hexlabel/toMods/ScriptMods/lua/hexlabel/. - Optionally place
FMF.HexLabelMod.dllinMods/(for MelonLoader metadata). - Launch the game — the config file is created automatically on first run.
Configuration
Edit UserData/hexposition.cfg to adjust label positioning and font sizes. The file is auto-generated with defaults on first launch.
# Hex Label Position Config
# File: UserData/hexposition.cfg
# Spinner (UI text near cable spool)
spinner_offset_x=0
spinner_offset_y=-6
spinner_font_min=1.8
spinner_font_max=6.2
spinner_font_scale=0.24
# Rack (world-space text at rack back-right-bottom)
rack_offset_right=-0.03
rack_offset_back=0.06
rack_offset_down=-0.02
rack_font_size=42
rack_character_size=0.05
rack_scale=1
Config Keys
| Key | Type | Default | Description |
|---|---|---|---|
spinner_offset_x |
float | 0 |
Horizontal offset relative to the source label |
spinner_offset_y |
float | -6 |
Vertical offset relative to the source label |
spinner_font_min |
float | 1.8 |
Minimum auto-size font size (TMPro) |
spinner_font_max |
float | 6.2 |
Maximum auto-size font size (TMPro) |
spinner_font_scale |
float | 0.24 |
Scale factor applied to the source label's font size |
rack_offset_right |
float | -0.03 |
World-space offset along rack's right axis |
rack_offset_back |
float | 0.06 |
World-space offset along rack's back axis |
rack_offset_down |
float | -0.02 |
World-space offset along rack's down axis |
rack_font_size |
int | 42 |
Font size for the world-space TextMesh label |
rack_character_size |
float | 0.05 |
Character size for the world-space TextMesh label |
rack_scale |
float | 1 |
Uniform world-space scale of the rack label object |
How It Works
- Startup — The Lua script defers initialization until MelonLoader's
Latest.logconfirms the Steam runtime is ready (scans viagreg.io.read_head). - Spinner labels — For each
CableSpinner, the script clones the sourceTextMeshProUGUIlabel viagreg.unity.instantiate()and configures it with the resolved hex code usinggreg.unity.tmpro_set(). - Rack labels — For each
Rack, a newTextMeshcomponent is created viagreg.unity.create_gameobject()+greg.unity.add_component()and positioned at the rack. - Scan loop — Active spinners and racks are re-checked every 1.5 seconds; deep refresh every 10 seconds.
- Harmony hook —
greg.hook.after()subscribes toCableSpinner.Startto label new spinners immediately on spawn. - HUD — IMGUI overlay drawn via
greg.gui.*inon_gui(), showing crosshair-aimed hex color detected viagreg.unity.raycast(). - Hex viewer — F2 toggles a full-screen color list collected from scene CableSpinners.
Migration from v00.01
If upgrading from the standalone C# version:
- Remove the old
FMF.HexLabelMod.dll(or keep it — the new version is just a bootstrap stub). - Install gregCore.
- Deploy
lua/hexlabel/main.luatoMods/ScriptMods/lua/hexlabel/. - Your
hexposition.cfgis fully compatible.
Sources
- Repository: github.com/mleem97/gregModHexLabelMod
- See also: Mods overview · HexMod hub