Skip to main content

Loading a Lua script

File structure

Scripts for H1-Mod should be placed in <MWR folder>/h1-mod/scripts/. You'll need to create a folder for your script and name it whatever you want (ex: my_basic_script). After that, the main file called by H1-Mod is named __init__.lua, so store your code that should be running first.

To figure out what your file structure should look like, refer to below:

Modern Warfare Remastered
โ”œโ”€โ”€ h1-mod
โ”‚ โ”œโ”€โ”€ scripts
โ”‚ โ”‚ โ”œโ”€โ”€ my_basic_script
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.lua
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ other_script.lua
โ”‚ โ”‚ โ”œโ”€โ”€ my_other_script
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ __init__.lua
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ script.lua
โ””โ”€โ”€ h1-mod.exe

After you setup your __init__.lua entrypoint, you can include other scripts. If you want to include another script (ex: other_script.lua), use the include function. This function will load the script using H1-Mod's functionality for loading scripts.

include("other_script")
--- [...]