As I got questions about Lua coding in HoI3 form time to time, I thought it might be good to have a place that shares some basic information about it all.

Afaik there is no real tutorila in HoI3-Lua coding. But you can get several Lua-coding tutorials.Lua modding HoI3 is about coding and knowing the game. It is a little bit different as to mod in events or new decisions. But it also has much more potentional and is open to more ways of creating a solution to your problem/idea.

That way the best advice is to know how to code Lua and check out the Lua tutorials for that.And to look at other mods wich changed the Lua of HoI3 to get some inspiration or reuse their code if possible.

At it is obvious that you can change and resue the Std-HoI3 code, I'll point out to info and some other mods that change the Lua code of Hearts of Iron III.

General coding Lua in HoI3.You can track errors in the "system.log" file the main "Hearts of Iron 3" folder.This folder is located:C:\Users\"your windows user acc"\Documents\Paradox Interactive\Hearts of Iron III\logs

Also you will notice lines in the code as such:--Utils.LUA_DEBUGOUT("Country: " .. tostring(ProductionData.ministerTag))If you uncomment them:Utils.LUA_DEBUGOUT("Country: " .. tostring(ProductionData.ministerTag))

You will get an entry of that variables in the file "lua_output.txt" wich you can find in the Main game folder of "Hearts of Iron 3".Look at HPP mod to see a good usage of the debugout. They made a more detailed "wrapper" to catch errors for testing.

Best things to get started would be to ask what you have in mind to change and then look for yourself in Std-HoI3 or other mods how it looks there.Then you can go on and change the code. And people on forums might also already give a helping answer.Also, Lua being a well known coding language, you can ask in several coding forusm about your code aswell.

For the coding as such, you can use any text editor you like. I used notepad+ and did all my modding with it. A great text editor wich also is capable of syntax highlightning, great search and replace functions, regular expressions and you can load up 2 different ai files to make a comparison, so you get highlighted the differences in the code. Thats a good way to see the different code sections more easily. There're also free IDE's like decoda or ZeroBrane free IDE's out there. Nice tools too.

Strat ai can't be changed directly. But indirectly. So Dr. Johnson(Initial Black ICE) was the first who showed officially that a different unit composition can lead to an ai on "steroids".Because the strat ai acts different if it has the "right" unit mix at hand. So a good production and research ai can lead to very different gameplay!

Good source for more different solutions/code/designs then vanilla are imo (in alphabetical order):AHOI-Mod: http://forum.paradoxplaza.com/forum/showthread.php?509632-gt-gt-AHOI-Mod-quot-A-HOI3-Treasure-Chest-quot-lt-lt-.Complete different design how to do production and research, but keeps pretty simple Lua coding, so it should be easy to rewrite. FTM code runs also faster as vanilla even in late war with just a changed production Lua. It is also a unique design wich has a connection between player and Lua. So ingame decsions can change the production ai wich will build different stuff. It started with "Pimp my HOI -Dynamic AI-":http://www.moddb.com/mods/pimp-my-hoi-dynamic-aiFirst HoI3-ai wich was more reacting to ingame situations and gives you the possibility to interact with this AI via decisions. So you could play with AI on full auto settings and concentrate on the war-action, while still changing the ai build options in a brader sense thrugh the decsions.So if you loose much convoys it will adjust the production rate accordingly! Even more so in war times. If you qonquered SOV you will switch to more naval units as GER and so on.

YAIIM: http://forum.paradoxplaza.com/forum/showthread.php?558868-MOD-Yet-another-AI-Mod-for-HOI3-FTM&highlight=The most ambitious project so far. AI that is really aware of its diplomatic situation and reacts based on that knowledge. AI that can react based on both historical and unhistorical behaviour of other countries (human especially). No more situations like USSR swallowing its neighbours and Axis/Allies are just waiting for its hardcoded decisions. Etc..It uses also a much more complex design/coding. This is very good if you want to dig deeper into Lua coding.

Last edited by Chromos on Sat Jan 30, 2016 7:14 am; edited 2 times in total

_________________

Play WW-I up to the Cold War! Soon possible with the "AHOI-Mod"! One of the most played Mods for "Hearts of Iron 3"!Spiele von dem WK-I bis zum Kalten Krieg! Bald möglich mit dem "AHOI-Mod"! Einem der meistgespielten Mod für "Hearts of Iron 3"!___- blog -___-facebook-___-twitter-___

The GER AI can already act quite well if it had some more ships like BB.F.e. invading Norway. It would have at least some units to use.. (Together with a slighly better air force that can be enough to hold its own in its own waters. )

With my production-Lua the build below is done from the ai all alone(Pimp my HOI -Dynamic AI).(A note to the low numbers for land units in '39. There is a switch to land units in '39 wich will focus on land units ongoing then until SU is defeated. So GER is strong enough to take on the Frenchmen and SU later on..)

(Some few BB in Production in '39, first will finish in ~'40.. Bismarck and Tirpitz will sail..)

(Some more air power too..)

And the result is a much more active Kriegsmarine..

_________________

Play WW-I up to the Cold War! Soon possible with the "AHOI-Mod"! One of the most played Mods for "Hearts of Iron 3"!Spiele von dem WK-I bis zum Kalten Krieg! Bald möglich mit dem "AHOI-Mod"! Einem der meistgespielten Mod für "Hearts of Iron 3"!___- blog -___-facebook-___-twitter-___