-
Notifications
You must be signed in to change notification settings - Fork 0
Pattern Library
TisonK edited this page Apr 9, 2026
·
2 revisions
30+ battle-tested code templates validated against production FS25 mods. These prevent common bugs and follow FS25 best practices.
"Starting from a pattern is always safer than starting from scratch. Ask me for a 'pattern reference' before building any new feature." 🎩☕
| Pattern | File | What it solves |
|---|---|---|
| GUI Dialogs ⭐ | gui-dialogs.md |
MessageDialog base class, XML layout, dynamic loading |
| Network Events ⭐ | events.md |
Multiplayer sync with read/writeStream |
| Save / Load ⭐ | save-load.md |
XML-based savegame persistence |
| Managers | managers.md |
Singleton global state across the session |
| Extensions | extensions.md |
Hook Giants classes with appendedFunction + cleanup |
| Field Detection ⭐ | field-detection.md |
Detect player's current field reliably (4-tier + 3-tier fallback) |
| Data Classes | data-classes.md |
OOP data containers with business logic |
| Message Center | message-center.md |
Subscribe to HOUR_CHANGED, DAY_CHANGED, etc. |
| Async Operations | async-operations.md |
Deferred/queued tasks without blocking |
| Financial Calculations | financial-calculations.md |
Loans, depreciation, collateral |
| Physics Override | physics-override.md |
Modifying vehicle/object physics |
| Shop UI | shop-ui.md |
Custom buttons in the vehicle shop |
| Placeable Purchase | placeable-purchase-hooks.md |
Dialog on placeable buy |
| Vehicle Info Box | vehicle-info-box.md |
Custom HUD info panel |
| Pattern | File | What it solves |
|---|---|---|
| Vehicle Specializations | vehicles.md |
Full spec lifecycle: onLoad → onUpdate → readStream/writeStream |
| Placeables | placeables.md |
Production points, interactive objects |
| Trigger Zones | triggers.md |
Enter/leave collision callbacks |
| HUD Framework | hud-framework.md |
Custom overlay elements (bottom-left origin!) |
| Animations | animations.md |
TweenSequence, setAnimTrackTime, conditionals |
| Animal Husbandry | animals.md |
AnimalHusbandryObject extension points |
| Production Chains | production-patterns.md |
Multi-input/output PlaceableProductionPoint |
| Vehicle Configs | vehicle-configs.md |
Wheel types, engine variants, custom configs |
-
Always use
MessageDialogas dialog base — neverDialogElement(causes white-box crash) -
Never use
onClose/onOpenas callback names — they conflict with GUI lifecycle methods -
HUD
mouseEventmust returntruewhen consuming — or clicks fall through to the game world -
Always uninstall
appendedFunctionhooks indelete()— they stack on savegame reload -
Wrap
getWorldTranslation()inpcall()— nodes can be invalidated at any time -
g_fieldManager.fieldsis empty at startup — never call field detection inloadMap()
Patterns provided by @XelaNull via the FS25 AI Coding Reference — validated against an 83-file production mod (FS25_UsedPlus) with 30+ custom dialogs.
Additional patterns contributed from FS25_SoilFertilizer and FS25_NPCFavor development.