2022-01-30 01:47:22 -05:00
# Lua Reference
The Lua scripting API is in early development.
Expect many more things to be supported in the future.
< br / >
## How to install Lua mods
2022-09-12 23:04:37 -04:00
Lua scripts you make can be placed either the `mods` folder in the base directory, or in `<SAVE FILE LOCATION>/mods`
Save file locations:
- Windows: `%appdata%/sm64ex-coop`
- Linux: `~/.local/share/sm64ex-coop`
- MacOS: `~/Library/Application Support/sm64ex-coop`
2022-01-30 01:47:22 -05:00
< br / >
2022-02-04 22:13:15 -05:00
## Tips
- When developing Lua mods, run the game from a console. Lua errors and logs will appear there.
- You can use the `print()` command when debugging. Your logs will show up in the console.
2022-03-17 01:55:16 -04:00
- You can create a folder within the mods folder containing multiple lua scripts as long as one script is called `main.lua` . Dynos actors can be placed inside this mod folder under `<your mod folder>/actors/` .
2022-02-04 22:13:15 -05:00
< br / >
2022-02-01 21:52:26 -05:00
## Sections
- [Globals ](globals.md )
2022-01-30 01:47:22 -05:00
- [Constants ](constants.md )
- [Functions ](functions.md )
- [Structs ](structs.md )
2022-09-12 23:01:45 -04:00
### Guides
2023-01-31 07:33:51 -05:00
- [Setting up Visual Studio Code ](guides/vs-code-setup.md )
2022-09-12 23:01:45 -04:00
- [Hooks ](guides/hooks.md )
- [gMarioStates ](guides/mario-state.md )
2023-01-31 07:33:51 -05:00
- [Behavior Object Lists ](guides/object-lists.md )
2022-01-30 01:47:22 -05:00
2022-03-05 02:20:53 -05:00
## Important notes on player indices
Something important to realize is that the `localIndex` for each player is different (unfortunately).
So the order of `gMarioStates[]` , `gNetworkPlayers[]` , and `gPlayerSyncTable[]` is different for each player.
Luckily `gPlayerSyncTable[]` will automatically translate the player indices, so setting `gPlayerSyncTable[0].example = 1` will set it for the correct player for everyone.
The `globalIndex` of each player is consistent among everyone connected. So if you absolutely need to sort things in order you will have to grab it from `gNetworkPlayers[<LOCAL INDEX HERE>].globalIndex` .
All of this is a holdover from when there were only two players. It was a reasonable idea back then.
< br / >
2022-03-19 03:59:06 -04:00
## Example Lua mods (small)
2022-05-08 03:26:55 -04:00
- [Low Gravity ](examples/low-gravity.lua )
2022-01-30 01:47:22 -05:00
- [Faster Swimming ](../../mods/faster-swimming.lua )
2022-04-13 04:38:32 -04:00
- [Mario Run ](examples/Mario-Run.lua )
2022-02-16 01:15:49 -05:00
- [HUD Rendering ](examples/hud.lua )
2022-02-26 03:03:21 -05:00
- [Object Spawning ](examples/spawn-stuff.lua )
2022-03-05 02:14:01 -05:00
- [Custom Ball Behavior ](examples/behavior-ball.lua )
2022-03-05 04:29:24 -05:00
- [Replace Goomba Behavior ](examples/behavior-replace-goomba.lua )
- [Add to Goomba Behavior ](examples/behavior-add-to-goomba.lua )
2022-03-10 01:58:45 -05:00
- [Behavior with Surface Collisions ](examples/behavior-surface-collisions.lua )
2022-03-31 00:36:47 -04:00
- [Custom Surface Collisions ](examples/big-paddle )
2022-03-17 01:55:16 -04:00
- [Custom Box Model ](examples/custom-box-model )
2022-03-18 00:41:46 -04:00
- [Custom Player Model ](examples/koopa-player-model )
2022-04-05 18:53:16 -04:00
- [Moonjump ](examples/moonjump.lua )
- [Instant Clip ](examples/instant-clip.lua )
- [Water Height Changer ](examples/water-level.lua )
2022-04-16 01:01:19 -04:00
- [Custom Level ](examples/custom-level )
2022-05-07 01:06:35 -04:00
- [Custom HUD Texture ](examples/custom-hud-texture )
2022-05-08 03:26:55 -04:00
- [Custom Audio Test ](examples/audio-test )
2022-03-19 03:59:06 -04:00
## Example Lua mods (large)
- [Extended Moveset ](../../mods/extended-moveset.lua )
- [Character Movesets ](../../mods/character-movesets.lua )
- [Hide and Seek Gamemode ](../../mods/hide-and-seek.lua )
- [Football (soccer) Gamemode ](../../mods/football.lua )