Tutorials — How to implement it
Task-oriented recipes: pick your goal, follow the steps, check the result. For full language tracks see Guidebook; for concepts see the Glossary.
Set up VS Code for modding
Section titled “Set up VS Code for modding”Goal: IntelliSense, snippets and one-click linting while you write.
- Install the extension gregCore Mod Tools (
mleem97, repo) — requires VS Code 1.93+. - Lua: open any
main.lua—greg.*completions, hover docs and lifecycle snippets work immediately, no setup. - JS: run GregCore: Setup JS IntelliSense inside your mod folder
— it copies the bundled
greg.d.tsand writesjsconfig.jsonso the built-in TS server completes thegregobject. - Optional but recommended: install the
greglintbinary and put it onPATH(settinggregcore.greglintPathoverrides the path). - Verify: type
greg.player.in a Lua file — you should seemoney,teleport, … with docs. See Guidebook Prerequisites for the game-side setup.
Scaffold your first mod
Section titled “Scaffold your first mod”Goal: a runnable mod folder in under a minute.
- Run GregCore: New Lua Mod… (or JS/Rust), pick the target folder, enter a lowercase mod id.
- Lua lands in
UserData/gregCore/Mods/Lua/<modId>/withmain.lua+mod.json; JS inMods/JS/<modId>/; Rust as a cargo crate (build to<game>/UserLibs/Rust/<modId>.dll). - Launch the game, open the backquote console, run
mods— your mod is listed. Press F1 to see it in the Mod Hub. - Details: Guidebook Lua 01 First Mod, Guidebook JS 01 Setup, Guidebook Rust 01 Setup.
Test and lint before you release
Section titled “Test and lint before you release”Goal: catch broken mods before they touch the game.
- Run
greglinton your mod folder (or gameMods/):greglint --severity-floor warning Mods/— exit0is clean. - In VS Code: GregCore: Lint Mod shows the same findings in the Problems panel; GregCore: Audit Mod / Project checks configs, JSON, changelogs and missing files without any binary.
- Fix what is reported (
--fixnormalizesmod.jsonwith a.bakbackup; IL findings stay manual, each carries a fix hint). - Gate releases in CI with
--format json(deterministic output). - Details: Developer GregLint.
Add a custom shop item
Section titled “Add a custom shop item”Goal: sell your own hardware in the vanilla shop.
- Register it (C#):
ShopAPI.RegisterItem(new CustomShopItem { Name, Price, TemplateType, TemplateID, Category, ... })— injection, layout, cart stacking and checkout are handled (greg.CommonShop, no manual UI cloning). - Optional:
BackgroundColor(card tint),Icon,CustomPrefab,OnBuy(purchase callback),OnUIReady(tweak the card),OnCheckout(quantity),ResultItemIDfor stable custom IDs. - Use high, stable, never-reused IDs; custom enum values are claimed persistently with cross-mod collision protection.
- Verify: open the Computer Shop, find your card in its category, buy it, check out, reload the save.
- Details: Developer Shop Items · meshes: Guidebook Modelling Shop Item.
Save and rebuy custom colors
Section titled “Save and rebuy custom colors”Goal: keep that perfect paint job available forever.
- Buy any item with a custom color from the color picker — the
preset is saved automatically
(
UserData/gregCore/CustomItemPresets.json). - Reopen the shop: your preset sits in the
Modscategory with its color and price (buyable only once the base item is unlocked — locked presets are greyed out). - Buying a preset puts the colored variant in the cart; plain buys next to custom cart lines stay plain.
- Details: Developer Shop Items.
Enable and disable mods without deleting
Section titled “Enable and disable mods without deleting”Goal: switch mods off (and back on) safely.
- Move the mod file or folder into a
.deactivatedfolder next to it (e.g.Mods/.deactivated/MyMod.dll); to re-enable, move it back out. Restart the game afterwards. - Nothing is ever loaded from
.deactivated— a disabled mod is fully inert. Only gregCore moves files, and only on your action. - If a moved mod still loads, a second active copy exists somewhere — search the folders for duplicates.
- Details: Player Mod Users Guide · terms: Glossary.
Ship a mod pack
Section titled “Ship a mod pack”Goal: distribute a curated set as one unit.
- Add
Mods/manifest.json:{ "Name": ..., "Mods": [...], "Library": [...], "Plugins": [...] }, paths relative toMods/. - Rules:
.dllonly, no path traversal, never anything under.deactivated.Libraryfolders feed dependency probing. Validate withgreglint(GL103) before shipping. - Details: Glossary (modpack manifest) · release flow: Guidebook Release · publishing: Developer Publishing.
Debug a broken mod
Section titled “Debug a broken mod”Goal: find the failing line fast.
- Reproduce once, note game/framework/loader versions
(console
`→version,mods). - Read the loader log top-down: registration →
[DynamicPatcher]→ your lines → first error. Lua runtime errors show as[LuaMod:<id>], JS as[gregCore][JS] <modId>/<file>. - Shrink it: F12 REPL for Lua (
greg.*live calls), minimal hook subscription,greg.ui.log_infocheckpoints. - Lua edits hot-reload on save; JS applies on next main-menu entry; C# needs rebuild + restart.
- Still stuck: FAQ Troubleshooting → mod tracker (single mod) or gregCore tracker (Hub/HUD/saves). Details: Guidebook Debugging.
Publish your mod
Section titled “Publish your mod”Goal: from working mod to Workshop release.
- Checklist: unique id,
mod.json/[GregMod]complete, save round-trip tested (save → load → remove mod → vanilla loads), co-op scope documented, diagnostics green. - Version with SemVer; never reuse shop/item IDs or GUIDs; keep
min_framework_versionaccurate. - Package per language, write the README (install, settings,
events, hotkeys), update
CHANGELOG.md(Unreleased). - Release on GitHub; Workshop releases join the GregCore Collection.
- Details: Guidebook Release · Developer Publishing.