-
Notifications
You must be signed in to change notification settings - Fork 41
LUI Scripting
fed edited this page Apr 29, 2022
·
3 revisions
H2-Mod supports loading custom LUI scripts that can be used to modify the game's UI and menus.
You can check out the game's decompiled LUI scripts here.
All scripts need to be placed in the ./ui_scripts
folder in your Call of Duty Modern Warfare 2 Campaign Remastered installation folder.
You will need to create a folder for your script, for example my_script
. The main entrypoint is always the __init__.lua
file in there.
The structure should be like this:
Call of Duty Modern Warfare 2 Campaign Remastered
├── ui_scripts
│ ├── my_script
│ │ ├── __init__.lua
│ │ └── other_script.lua
│ ├── my_next_script
│ │ ├── __init__.lua
│ │ └── script.lua
└── h2-mod.exe
To load another script, you can use the require
function.
If you want to for example include other_script.lua
, use it like this:
require("other_script")
-- [...]
function mymenu(a1)
local menu = LUI.MenuTemplate.new(a1, {
menu_title = "MY AWESOME MENU",
exclusiveController = 0,
menu_width = 240,
menu_top_indent = LUI.MenuTemplate.spMenuOffset,
showTopRightSmallBar = true
})
local button = menu:AddButton("BUTTON NAME", function()
print("Button clicked")
end, nil, true, nil, {
desc_text = "BUTTON DESCRIPTION"
})
menu:AddBackButton(function(menu)
Engine.PlaySound(CoD.SFX.MenuBack)
LUI.FlowManager.RequestLeaveMenu(menu)
end)
LUI.Options.InitScrollingList(menu.list, nil)
menu.optionTextInfo = LUI.Options.AddOptionTextInfo(menu)
return menu
end
LUI.MenuBuilder.m_types_build["my_awesome_menu"] = mymenu
Executing lui_open my_awesome_menu
will open the menu.
You can find more example scripts here.