Tutorial: Example Project
Example project
Example project: To make a new mod, you have to create a new folder, named as the mod you want to create, in the following directory:
Then, you have to create a new :::cpp main.lua
file in the newly created folder. This file can then be used to contain the logic behind your mod.
:fontawesome-brands-linux: For Linux {: .subHeader .notes }
Mod tools aren't available in the native version. You need to run the game with Proton, the folder location is going to be inside your Steam folder
:fontawesome-solid-code: Example "main.lua" {: .subHeader .example_code }
This code creates a mod, that turns tears into dark matter tears (slowing black tears). It also adds one coin to the player every shot.
:fontawesome-solid-code: Local function example {: .subHeader .example_code }
Differences to the other method:
Instead of the function being stored inside of the mod variable it is it's own variable local to the level of creation. When creating a local function the first parameter looks for itself and this argument is commonly disregarded by storing it as an underscore. When calling/triggering this function only the function name is necessary, as it is not stored within the mod variable. Local functions are able to be stored within a table just like any other variable, for example:
where this function would be called via functions[1], and is used in place of onTear in the AddCallback function of the main example Example code:
:fontawesome-solid-code: "Inline" definition of functions example {: .subHeader .example_code }
Differences:
In this example the function being triggered by the callback is defined within the AddCallback function. This method of creation removes the need for storing and referencing your function from a variable, similarly to the local function example the function given will attempt to pass itself has the first argument so it is disregarded with an underscore. Since this function is not stored within your code it is not possible to call it from other places, so this method should only be used if it is to only be triggered by the callback
Last updated