This is the rough beta for my Total War Warhammer3 lua debugger.
Download the lua debugger tools from steam workshop and activate them
In VSCode, go to the Run and Debug page (ctrl+shift+d) and add the following new debug configurations. For example, the following:
In order to debug lua files, you need to extract them from the packfile they are in, and place them in the "sourceBasePath".
sourceBasePath defaults to the vscode workspace directory which defaults to be "C:..\steamapps\common\Total War WARHAMMER III" in the config
For example you want to debug the warhammer3 CA lua files in data.pack
- Open "C:..\steamapps\common\Total War WARHAMMER III/data/data.pack" in RFPM
- Richt-click the "script" folder and extract the folder to "sourceBasePath" folder. Default is: ("C:..\steamapps\common\Total War WARHAMMER III")
- in VSCode go to Run and Debug (ctrl+shift+d), and use the tw-attach-warhammer3 configuration to attach to warhammer3 or launch to launch warhammer3
!Make sure that the lua debugger mod is listed in "common\Total War WARHAMMER III\used_mods.txt" when launching from vscode!
- Stepping over, in and out
- Inspect local and global variables
- Print to vscode from lua. debuggee:print("warning", "some warning") (categories are "warning", "error", "log")
- Pausing (see limitations and quirks)
Limitations and quirks
- Debugger (re)connects everytime warhammer3 switches environment (frontend/campaign/battle), meaning the debugger needs to be active before entering an environment in order to work
- It is best if the debugger is running before warhammer3, or warhammer3 is started via the vscode debugger
- Pressing pause in vscode will not stop warhammer3 where it is executing in lua, but inside either twdt_frontendstart.lua, tw_battle.lua or tw_campaign.lua
- Pausing does not work during load screens
- Disconnecting and reconnecting the debugger from vscode is not advised, but seems to work.
- Source file extraction from used packfiles directly
- Break on error
This debugger is a changed version of the devcat LUA debugger: