3.5 KiB
3.5 KiB
Copilot instructions for gta5-chaos-luascripts
These notes help an AI coding agent make productive, targeted edits to this repository.
- Project purpose
- This repo is a collection of Lua effects for the GTA V Chaos Mod runtime. Each file defines one effect that the Chaos Mod loader expects to find and execute.
- Key file patterns
- Every effect defines an
EffectInfotable and three lifecycle functions:OnStart(),OnTick(), andOnStop(). - Example files: Player/PlayerTPEverythingAway.lua, Player/PlayerAnnoyingRCVehicle.lua, Peds/PedsClowningAround.lua, Misc/MiscCleanUp.lua.
- Naming & metadata conventions
EffectInfo.EffectId: unique, snake_case id (prefixes used includeplayer_,peds_,veh_,misc_). Keep ids stable to avoid breaking saved configs.TimedType: one ofNone,Normal,Short,Permanent, orCustom(setCustomTimewhen usingCustom). SeePlayerTPEverythingAway.luafor examples.EffectGroup/EffectCategory: optional grouping used by the mod UI—preserve existing values when editing.
- API and runtime expectations
- Scripts call Chaos Mod runtime helpers and GTA native functions (e.g.
GET_ENTITY_COORDS,SET_ENTITY_COORDS,GET_HASH_KEY). Do not assume standard Lua libraries beyond basic math/table/string. - Use provided helper functions like
GetAllVehicles()andGetAllPeds()when present. Heavy work should be bracketed withEnableScriptThreadBlock()/DisableScriptThreadBlock()as shown inPlayerTPEverythingAway.lua. This prevents mission breakage.
- Safe editing practices
- Keep
OnTick()lightweight. Per-file patterns useOnStart()for heavy one-off operations andOnStop()for cleanup (seeMisc/MiscCleanUp.lua). - When adding model/ped/vehicle creation, call
SET_MODEL_AS_NO_LONGER_NEEDED()after spawning and set network flags where existing files do.
- Debugging & testing
- Runtime: these scripts are loaded by the Chaos Mod runtime. The README explains how to install effects into
ChaosMod/Effects— follow those steps to test in game. - Use
print()statements for minimal runtime logs; prefer non-destructive testing (temporary vehicles/peds) and ensure cleanup inOnStop().
- Code style & idioms to follow
- Minimal globals: existing scripts set a few globals (e.g.
playerPed) inOnStart()— match existing style rather than introducing module systems. - Prefer small, focused changes: add helpers at the bottom of the same file unless the change is shared across many effects.
- Integration & external dependencies
- This repo depends on the external Chaos Mod loader and GTA Natives—do not attempt to refactor away from those calls.
- What not to change
- Do not rename
EffectInfo.EffectId, remove lifecycle functions, or changeTimedTypesemantics without updating any UI grouping logic (not present in this repo).
- If you need more context
- Read the top-level README.md and review representative scripts in
Player/,Peds/,Vehs/,Misc/to learn common helpers and patterns.
If anything is unclear or you want additional examples (naming, timing, or network-safe spawning), tell me which area to expand.
- External References
- Chaos Mod Lua Scripting Wiki:
(https://github.com/gta-chaos-mod/ChaosModV/wiki/Lua-Scripting) - GTA V Natives Reference:
(https://nativedb.scheenen.dev/natives) - Example Effect Template:
(https://gitea.nathan-falvey.synology.me/Templates/gta5-chaos-luascript-template)