Can I make use an array to create decisions?
Hi folks
I'm trying to make a mod that allows you to join any faction that exists through decisions.
Do I have to make a decision for each country tag or can I use an array with all the country tags in it?
Thank you for any help in advance :)
Posted Feb 15, 2022, 2:07 PM UTC
For what exactly do you need the tag? If it's for the country that fires the event you should be able to just use ROOT in place of a specific tag.
My thought was a for each loop with an array of country tags. This loop makes the decisions for each country tag instead of creating a file with 241 individual decisions .
(my primary coding experience is java from 7 yrs ago so I'm very rusty)
Pastebin with pseudoish code
Sadly, there are no arrays in hoi4, nor are there loops. I could think of a way to add someone to a random faction, but not to a specific faction that isn't predetermined.
So the only way would be to either create a decision/event for every single tag (which would break compatibility for total conversions, and is just a huge time waste), or you could do it in the same way the "toolpack" mod does it. Sadly I don't know about modding interactable interfaces, so I can't help there.
I'm happy to inform you that you are mistaken. There are arrays in HOI4 code and there are loop effects that can be used on them: https://hoi4.paradoxwikis.com/Arrays#for_each_loop
Oh, I didn't know that. From what I saw on the site it would probably still not be applicable in this situation, tho. It is however very interesting, so thanks.
I'm genuinely surprised, are arrays ever used in the base game? I never saw one and I pretty much went trough half the games events and decisions before.
Thank you Icy.
A file with all tags would be 2-3 mb if pure text :D So yeah that would be silly.
Your answer saved me a lot of wasted time.