Basic info for Hearts of Iron III Lua modding

View previous topic View next topic Go down

Basic info for Hearts of Iron III Lua modding

Post  Chromos on Fri Jan 29, 2016 11:39 pm

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. Smile
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!



A good site with overall info is also:
http://code.google.com/p/hoi3-ai-improvement-pack/wiki/LUAClassReference
Informations about HoI3 Lua from the AIIP project.



MODS:
For "vanilla like code", if you mostly want to look how you could change the vanilla code.


TFH 4.02 LUA optimizations by peterhoi3: make the USA count! and other repairs:
http://forum.paradoxplaza.com/forum/showthread.php?650333-TFH-4.02-LUA-optimizations-by-peterhoi3-make-the-USA-count!-and-other-repairs
Improves the TFH ai with good slight changes here and there. Best way to look how slight changes can make a big difference.

Same goes to Mechanized War/RPM/DWI and some others wich "just" changed the code/design of vanilla to improve the ai, look here:
http://forum.paradoxplaza.com/forum/forumdisplay.php?537-Other-mods-and-projects


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. Smile
It started with "Pimp my HOI -Dynamic AI-":
http://www.moddb.com/mods/pimp-my-hoi-dynamic-ai
First 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.

AIIP: http://forum.paradoxplaza.com/forum/forumdisplay.php?469-AI-improvement-pack
It has a far more advanced ai then vanilla. Great ideas and improvements. Sadly no longer developed, but worth a look anytime! They also did the info gathering I posted above. Great knowledgable Lua coders.

HPP: http://forum.paradoxplaza.com/forum/forumdisplay.php?531-The-Historical-Plausibility-Project
Is an overall improvement of the vanilla ai wich improves the std code by an great amount. It also has a solution for an information dumper. So you could get more detailed information about a crash.

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-___

Chromos
Admin

Posts : 568
Join date : 2011-11-01

http://ahoimod.wordpress.com/

Back to top Go down

Old teaser from "Pimp my HoI"

Post  Chromos on Fri Jan 29, 2016 11:42 pm

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. Wink )

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-___

Chromos
Admin

Posts : 568
Join date : 2011-11-01

http://ahoimod.wordpress.com/

Back to top Go down

Big cauldron with different units production

Post  Chromos on Fri Jan 29, 2016 11:44 pm

Biggest wandering cauldron I've seen so far.
All actors AI,  one of the Testgame for AHOI-Mod(FTM) production Lua.

In the end I forgot who won.  IIRC it was one of the games were the allies managed to win in late '47 due to a huge landing in Europe(south and north simultaneously).


The germans move out for a gigantic encirclement..




Closing in..




CLOSED.. and over?




Moscow holds the line!




Thats it.. or?




Break free comrade! We need a harbour!




Moskow is lost, but the Russians broke finally free again..

_________________
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-___

Chromos
Admin

Posts : 568
Join date : 2011-11-01

http://ahoimod.wordpress.com/

Back to top Go down

Re: Basic info for Hearts of Iron III Lua modding

Post  Sponsored content Today at 5:07 pm


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum