Solved lua modScript documentation

Discussion in 'Mod Support' started by fillman86, Aug 25, 2025.

  1. fillman86

    fillman86
    Expand Collapse

    Joined:
    Apr 18, 2020
    Messages:
    206
    This is half; an explainer for beginners; a request to fill in gaps in my knowledge. So please comment below if you find mistakes, or can do a better job at explaining modScrip.lua though this is only temporary, until the page is added to the new documentation site.

    MODSCRIPTS:
    If you make a lua mod, it can be activated in a few ways, including calling it from a jbeam part that has it set as a controller. From there, that can activate other lua files, even gelua with things like this - https://documentation.beamng.com/modding/programming/virtualmachines/

    However, if you don't have a parts aren't relevant to your mod, then you'll need to activate it somehow, at some point, and that's normally done with the modScript.lua file. In your mod's root directory, create a "scripts" folder, in there create a unique folder name (no spaces or special characters), in that folder, create "modScript.lua" and in there you'll load your mods.

    eg, this loads 2 separate files, 1 in vlua, and one in gelua-
    load("extensions.colourChange/geColourChange") --extension to load
    setExtensionUnloadMode("colourChange/geColourChange", "manual") --something about unloading the mod?
    load("extensions.colourChange/geMultMighty") --extension to load
    setExtensionUnloadMode("colourChange/geMultMighty", "manual") --something about unloading the mod?

    this loads, and sets up unloading of the mod, and is read when the game is launched. If your mod is an extension and in the extensions folder tree, then you don't need to write "lua/ge/extensions..." or similar, just "extensions." then your file's path, but no need to write ".lua" at the end. This (I believe) is the same for files in vehicle/extensions, ge/extensions, and common/extensions

    If you're not loading an extension, then your path will look a little more like this;
    load("common/utils/simpleProfiler/report"
    or
    load("utils/simpleProfiler/report"
    (depending on luck I suppose)

    If you're adding keybinding json stuff, you may want to also use this to create a new category:
    extensions.core_input_categories.colourChange = { order = 500, icon = "settings", title = "Change Colours", desc = "Changes the Special Colours"}--set keybindings to load

    That last example uses the "extensions." prefix, but uses _ instead of / for the folder directory (I'm unsure why/when it's written this way sometimes, and not in other places). Then the file doesn't use _ or / but . instead. Then there's "order" which should set the order in relation to other main categories like "Vehicle", "General", and "Gameplay". "icon" is to set the icon you'll see next to the title, "title" is basically the name, "description" is (I think) for mouse hover text.

    Basically, make scripts/RANDOMFOLDERNAME/modScript.lua and put in the "load" and "setExtensionUnloadMode" stuff. If you're adding a keybinding category (alternatively you can just use a preexisting category that fits), you won't need to activate the file at all, but you'll need to add the category here.

    I'll attach an example file with the stuff above
     

    Attached Files:

    • Like Like x 2
  2. EuncNcap

    EuncNcap
    Expand Collapse

    Joined:
    Oct 26, 2023
    Messages:
    16
    i dont understand it very well, it seem to be some scripts? idk, but im with a lua that supposes to convert a broken beam (with wantedbeam) to an electrics sign, but i don't know, Sorry if this has nothing to do with what you say, but I really need help.
     

    Attached Files:

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice