Modular Lua

Visual Studio Code Setup

How to install the auto-complete addon for Modular Lua modding:

  1. Download the modsa.d.lua definition file from the Modular channel. It is pinned. Place the file somewhere easily accessible.
  2. Open VSC, and install the Lua Language extension by sumneko.
  3. Open the settings.json. You can easily do this by opening the command palette with CTRL+SHIFT+P, then accessing the User Settings JSON file.
    Palette
  4. Type in a new variable in the form of:
    "Lua.workspace.library": []
    Then write in the path to the FOLDER that contains the modsa.d.lua file you downloaded. Example:
    ConfigFile
  5. Re-open VSC. It should now be capable of autocompleting your Modular lua scripts.

Lua-specific Modular methods.

credit: Shane & Nylon.

setldata(var_1, var_2, var_3)

Sets encounter-persistent data from the target.

  • Arguments:
    • var_1: See Single-Target
    • var_2: String (The Data ID)
    • var_3: Any .lua value (The value to be set)

credit: Shane & Nylon.

getldata(var_1, var_2)

Gets encounter-persistent data from the target (Lua version)

  • Arguments:

credit: None.

clearvalues()

Clears the value of a Modular script

credit: None.

resetadders()

Clears the adders of a Modular script

credit: Shane & Nylon.

require("XXXX")

Loads the content of another .lua file in the modular_lua folder. (i.e require("killallzenos")). Act's like normal inheritance.

credit: Shane & Nylon.

selecttargets(var_1)

Takes a multi-target selector string and returns an table of selected targets. (i.e ["inst12", "inst34"]). Inst selectors are recognized by Modular, meaning you can pass them into consequence/value acquirers that accept target selectors.

credit: Nylon.

listfiles(var_1)

Lists the files of a given directory. This function does NOT list folders. This function is restricted to the "Plugins" folder and any sub-folders. This function returns a .lua array.

  • Arguments:
    • var_1: Path of the directory (i.e "Lethe")

credit: Nylon.

readfile(var_1)

Reads a given files contents. This function is restricted to the "Plugins" folder and any sub-folders. This function returns a .lua string.

  • Arguments:
    • var_1: Path of the file (i.e "Lethe/modularcodesecrets.txt")

credit: Nylon.

listdirectories(var_1)

Lists the folders of the directory specified. This function does not list files, and is restricted to the Plugins folder and any sub-folders. This function returns a .lua array.

  • Arguments:
    • var_1: Path of the directory (E.X: "Lethe")

credit: Nylon.

jsontolua(var_1)

Converts a string representing JSON's into a lua table. (Use with readfile(), listfiles(), and listdirectories())

  • Arguments:
    • var_1: Any string

credit: None.

listbuffs(var_1)

Returns a .lua array containing all the keywords a unit has.

credit: Nylon.

setgdata(var_1,var_2)

Sets a global .lua value, which is only cleared upon a total game refresh.

  • Arguments:
    • var_1: String (The data ID)
    • var_2: luaValue: a .lua value

credit: Shane.

addresource(var_1, var_2, var_3)

Gives or Removes Sin Resource from a team.

  • Arguments:
    • var_1: CRIMSON | SCARLET | AMBER | SHAMROCK | AZURE | INDIGO | VIOLET
    • var_2: VALUE_# | any integer (Amount of resource generated. Can be negative to remove resource)
    • opt_3: Enemy (Add this optional argument to affect the enemy team)

credit: Nylon.

getgdata(var_1)

Returns a global .lua value.

  • Arguments:
    • var_1: String (The data ID)

credit: Nylon.

clearallgdata()

Clears all currently loaded .lua global values.

Math Functions (.lua only)

Refer to this website

credit: None.

gbkeyword

Returns a string representing the buff keyword gained (Only works with OnGainBuff timing)

LUAMAIN Function

LUAMAIN is a Main Function that lets you trigger a specific LUA function in a lua file
See This Part of the Documentation

Edit

Pub: 29 Oct 2026 14:03 UTC

Edit: 30 Oct 2026 04:09 UTC

Views: 374