Total War: WARHAMMER III

Total War: WARHAMMER III

47 ratings
Execute External Lua File (Modding Tool)
   
Award
Favorite
Favorited
Unfavorite
campaign
Tags: mod
File Size
Posted
Updated
107.882 KB
9 Apr, 2022 @ 3:34am
29 Dec, 2024 @ 8:18am
4 Change Notes ( view )

Subscribe to download
Execute External Lua File (Modding Tool)

In 1 collection by prop joe
Prop Joe Mods
20 items
Description
Executes a Lua script ingame when you press F9, with the goal of assisting modders during script development. If you want to make script mods I highly recommend you use this mod when creating them.

First you need to manually create the actual file the mod will use: create a file named exec.lua inside steamapps\common\Total War WARHAMMER III

Paste this inside the file:
cm:treasury_mod(cm:get_local_faction_name(), 10000)
and if you have the mod enabled and press F9 ingame, the script will run and you will get 10000 gold.
Every time you press F9 the script gets run again and you get more gold every time you re-run the script.

The goal of this mod, however, is not cheating in gold, but allowing for faster development of scripts.
The general idea is to move all of the scripting during development into external files, outside of packs. Put the scripts into packs when you serve the mod to the users.
Once the mod gets released you can also just isolate specific functions or listeners from your mods to modify and test.
During development you can build your scripts in pieces ingame without having to restart the game (basically we can have hot-reloading).

I'll try updating this introduction so you can see what I mean, more here:
https://gist.github.com/Shazbot/a49b438bef8ae2bb246334198e1ef475

Note you have to have F9 bound to "View camera bookmark 1" in the controls in the options, but it should be bound by default.

Other mods of interest to modders:
Draw Debug Logs (WH2) from WH2 is now included in this mod, check out the page for the documentation, it allows you to print out Lua types onto the screen for debugging, you can also dump things into a file.
Script Debug Activator also allows you to get feedback from your scripts using out.

You can find the scripting docs here[chadvandy.github.io].

My other guide on Lua WH2 modding.[shazbot.github.io]

Other Notes
Works in battles using a exec_battle.lua file you can make, that runs when you press F9, credits to ShadowCX for helping getting it to work

Works in frontend using a exec_frontend.lua file you can make that gets executed when you press the new button in the top left in the frontend. Note that callback doesn't work in the frontend, but you can use real_timer to delay stuff in the frontend.
This snippet will dump the UI after a 5 sec delay:
https://gist.github.com/Shazbot/edb8a3af536e35c030c1c29f46d5b800

You can make a exec_first_tick.lua.lua file, code inside that file will get auto-executed inside a cm:add_first_tick_callback, so you can test stuff that would get run through that. Don't forget stuff you put there stays there on every campaign load.

You can also make an additional exec2.lua file that gets executed with F10, the extra file can create a better coding workflow.

When doing UI scripting inside panels that don't trigger the F9 shortcut you can use the "e" command in my Console Commands mod as a workaround.

Also, if the mod doesn't find exec.lua inside the Total War WARHAMMER III folder it will also check Total War WARHAMMER III/exec/exec.lua.
So basically you can put exec.lua and all the other files inside an intermediate exec folder so things are better structured. But you don't have to.
25 Comments
BrutusCz 11 Jun, 2024 @ 12:08pm 
When I started learning some scripting, I would be absolutelly lost without this. It's amazing to just see things in real time.
Loyd88 29 May, 2024 @ 10:49pm 
@Aisede often in Windows, files extentions are hidden, so you must rename the "exec.lua" from File Explorer (in Win 11). Because right now is "exec.lua.txt" that's why it cannot find the file
Spell 23 Oct, 2023 @ 6:14pm 
Thank you, this mod is invaluable for mod-making.
prop joe  [author] 13 May, 2023 @ 11:57am 
considering I was using this to mod last week the mod itself works fine
ReinHarD 9 May, 2023 @ 10:12am 
Can this mod still work now?
I tried the steps in the introduction and confirmed that my F9 is bound to "View camera bookmark 1", but I created a game and pressed F9, but nothing happened.
Playmate 20 Mar, 2023 @ 11:15pm 
This is incredibly useful, thanks man!
prop joe  [author] 10 Mar, 2023 @ 3:08pm 
I'm not sure but if a function starts with dev it usually means it's only usable in the dev version of the game we don't have access to
Joey Jo-Jo Jr Shabadoo 10 Mar, 2023 @ 11:28am 
Im trying to use this to change the UI scale to a value lower than 1. "DevSetUiScale(0.9)".
Is it possible to call this function with this mod?
Freiya 27 Jan, 2023 @ 3:22am 
Thanks for the mod, it's extremely useful.
Silito13 24 Jan, 2023 @ 11:30am 
Is there a way to progress the Prophecy of Sotek with this? Stuck on the first stage after completing everything