Skip to content

Latest commit

 

History

History
77 lines (62 loc) · 3.44 KB

File metadata and controls

77 lines (62 loc) · 3.44 KB

Lua Reference

How to install Lua mods

Lua scripts you make can be placed either the mods folder in the base directory, or in <SAVE FILE LOCATION>/mods. You can also drag and drop mods into the window to install them.

Save file locations:

  • Windows: %appdata%/sm64coopdx
  • Linux: ~/.local/share/sm64coopdx
  • MacOS: ~/Library/Application Support/sm64coopdx

Tips

  • When developing Lua mods, open the console with ~ or F1 to see Lua errors and warnings.
  • When a function requests a time parameter, it is almost if not always in frames.
  • You can use the print() command when debugging. Your logs will show up in the console and terminal.
  • 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/.
  • If you're just starting out, you should take a look at the guide for creating a mod.

Sections

Guides

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.


Example Lua mods (small)

Example Lua mods (large)