diff --git a/docs/lua/globals.md b/docs/lua/globals.md new file mode 100644 index 00000000..308d5d50 --- /dev/null +++ b/docs/lua/globals.md @@ -0,0 +1,38 @@ +## [:rewind: Lua Reference](lua.md) + +# Globals +Globals are variables that are always exposed to the Lua API. + +
+ +## [gMarioStates](#gMarioStates) +The `gMarioStates[]` table is an array from `0` to `(MAX_PLAYERS - 1)` that contains a [MarioState](structs.md#MarioState) struct for each possible player. + +It is indexed by the local `playerIndex`, so `gMarioStates[0]` is always the local player. + +[:arrow_up_small:](#) + +
+ +## [gCharacter](#gCharacter) +The `gCharacter[]` table is an array from `0` to `(CT_MAX - 1)` that contains a [Character](structs.md#Character) struct for each possible character. + +[:arrow_up_small:](#) + +
+ +## [gGlobalSyncTable](#gGlobalSyncTable) +The `gGlobalSyncTable` is a table used for networking. Any field set inside of this table is automatically synchronized with all other clients. Do not use this table for player-specific variables, keep those in [gPlayerSyncTable](#gPlayerSyncTable). Player-specific variable will desynchronize within this table since it doesn't automatically translate `playerIndex`. + +[:arrow_up_small:](#) + +
+ +## [gPlayerSyncTable](#gPlayerSyncTable) +The `gPlayerSyncTable[]` is an array from 0 to `(MAX_PLAYERS - 1)` that is used for networking. Any field set inside of this table is automatically synchronized with all other clients. + +It is indexed by the local `playerIndex`, so `gPlayerSyncTable[0]` is always for the local player. + +The underlying networking system will automatically translate the local `playerIndex` so that the field is set for the correct player. + +[:arrow_up_small:](#) diff --git a/docs/lua/lua.md b/docs/lua/lua.md index 157d305d..99c736e2 100644 --- a/docs/lua/lua.md +++ b/docs/lua/lua.md @@ -11,15 +11,8 @@ Lua scripts you make can be placed either the `mods` folder in the base director
-## Globals -| Identifier | Type | Description | -| :-------- | :--: | :---------: | -| gMarioStates[MAX_PLAYERS] | [MarioState](structs.md#MarioState) | An array of length MAX_PLAYERS containing mario states | -| gCharacter[CT_MAX] | [Character](structs.md#Character) | An array of length CT_MAX containing character information | - -
- -## Exposed from SM64 +## Sections +- [Globals](globals.md) - [Hooks](hooks.md) - [Constants](constants.md) - [Functions](functions.md)