• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Not in a way that makes me feel good inside.

You could have events that run all the time, waiting for flags to be set. But that makes me feel ookey inside.

What are you trying to accomplish? Perhaps knowing that will make it easier for us to help you find the best solution.
 
,
Not in a way that makes me feel good inside.

You could have events that run all the time, waiting for flags to be set. But that makes me feel ookey inside.

What are you trying to accomplish? Perhaps knowing that will make it easier for us to help you find the best solution.

This is going to be part of the supply-and-demand system for a trade mod. There are a bunch of province-level variables and flags, most notably the generic demand variable, which are only initialized when the province is connected to a trade network and might therefore actually need them, to save on processing and memory. There are a bunch of different events that hook a province up to a trade network, and each one needs to check that these variables are initialized and, if they aren't, initialize them, before running the rest of its calculations. The initializations are long enough that I'd like to outsource them to a separate event rather than repeat them in each event, but I can just hit copy-and-paste a bunch of times if that's the only way to do it.
 
I need help with one more thing unfortunately, after testing for about an hour and trying different things and combinations of things. I have a special decision which converts the taker's religion and gives them the religious head title for that religion. Unfortunately, no matter what I do (eg set_government_type = feudal_government), it still converts the holder to either "no government" or theocracy, depending on whether or not the player or AI created it respectively. In landed_titles, this is what the code looks like:

Code:
d_satan_state = {
    color={} ##########
    color2={} ##########
    capital = 333 #######
    title = "ANTICHRIST"
    title_female = "FEMALEANTICHRIST"
    foa = "ANTICHRISTFOA"
    short_name = yes
    location_ruler_title = yes
    landless = no
    controls_religion = satanism
    religion = satanism
    dynasty_title_names = no
}

It's essentially no different to the fylkirate which permits normal playable government types.
Try "caliphate = yes". I think the reason the Fylkirate doesn't have this is because the reformer_head_of_religion tag does it anyway. Non-reformed religions need the caliphate tag to allow them to be held by feudal characters.
 
Try "caliphate = yes". I think the reason the Fylkirate doesn't have this is because the reformer_head_of_religion tag does it anyway. Non-reformed religions need the caliphate tag to allow them to be held by feudal characters.
That doesn't work unfortunately. It's strange how it even says in the in-game religion description that the title is held by a secular ruler. I've tried having the title created normally, not by decision, and it still turns the ruler into a theocracy.
 
I have a question about threading. I know that the game uses multi-threading for events to improve computation. I have a pair of events I want to fire, call them asnys.1 and asnys.2. They need to fire in sequence, first asnys.1 and, only when it's finished, then asnys.2. If I call:

Code:
immediate = { province_event = { id = asnys.1 } }
after = { province_event = { id = asnys.2 } }

Will asnys.1 fire and, only once it's resolved, asnys.2 fires? I know I could just make asnys.2 fire with a day's delay, or have asnys.1 call it, and that would work, but for reasons not worth getting into it would mean I would need to write a lot more code, which I obviously prefer to avoid.
The easiest way to do this would be - in case both events always fire in this order - to just call event No1 immediately, and let event No1 call event No2 in its after clause.
That would make event 2 only fire once event 1 is resolved. Unless I understand something wrong...
,

This is going to be part of the supply-and-demand system for a trade mod. There are a bunch of province-level variables and flags, most notably the generic demand variable, which are only initialized when the province is connected to a trade network and might therefore actually need them, to save on processing and memory. There are a bunch of different events that hook a province up to a trade network, and each one needs to check that these variables are initialized and, if they aren't, initialize them, before running the rest of its calculations. The initializations are long enough that I'd like to outsource them to a separate event rather than repeat them in each event, but I can just hit copy-and-paste a bunch of times if that's the only way to do it.
Interestingly, I had quite similar problems with some mod I am working on.
I ended up outsourcing most of the "repetitive" checks to scripted_triggers and scripted_effects.
For example, in my mod I need to check if a province with a certain modifier is within a certain distance of another province, depending on a few other factors. Since this check was really extensive and long, but stayed the same every time, I made the code into a scripted_trigger, and then called that thing in my events every time I needed it. Like this
Code:
option = {
    trigger = {
        is_within_range_mytrigger = yes    # Evaluates distance based on terrain etc.
    }
    #... other stuff
}

option = {
    trigger = {
        AND = {
            is_within_range_mytrigger = yes    # Evaluates distance based on terrain etc.
            has_enough_feudal_holdings_mytrigger = yes # Checks if province has a certain amount of holdings (of castle, temple or city type)
        }
    }
    #... other stuff
}
where the things like "is_within_range_mytrigger" are defined in another file. It's a bit easier than having another event handle the calculations imo, since you can also call these multiple times in the same event, say one in immediate block, one in options block and one in after block, without interrupting the current event!
Of course the full events are a lot longer, but this "outsourcing" of repetitive checks, or also effects, has really simplified my code. These things are kinda like "functions" in regular programming, with the only downside being that you can't directly give them any numbers to change. But you can workaround that by setting a variable before calling the scripted_effect and have that effect check or multiply that variable.
Okay I hope I did not sound too strange, but from personal experience I am pretty sure these things work well with your type of mod - you should probably check out the wiki (http://www.ckiiwiki.com/Scripting#Scripted_block) to get a more comprehensive explanation ^^
 
How do buildings influence Government when working out History at the Map Screen?

Situation:
1) Launch game
2) Click 'Single Player'
3) Go to 'Government Types'
4) Find that a load of Provinces have changed their Government from what they should be.

I've narrowed it down to a Mod that adds a few new buildings, and tweaks the vanilla ones, but I cannot see why this would alter the actual Government set-up of these Provinces, since these specific Provinces are never touched by my Mod or any of the others I am running.
 
Okay I hope I did not sound too strange, but from personal experience I am pretty sure these things work well with your type of mod - you should probably check out the wiki (http://www.ckiiwiki.com/Scripting#Scripted_block) to get a more comprehensive explanation ^^

Thank you, I think this may be exactly what I'm looking for. So if I use a scripted effect, the code executes before the rest of the code in the function does? It's basically like I copy-and-pasted?
 
Thank you, I think this may be exactly what I'm looking for. So if I use a scripted effect, the code executes before the rest of the code in the function does? It's basically like I copy-and-pasted?

Yep :) Once it hits the Scripted Trigger, it goes off and runs all those commands, and then comes back to carry on.
 
Has anyone else had problems with an artifact's "active" section? What I'm seeing is that at least some character conditions don't work correctly. They'll appear as green in the artifact's popup description in the treasury, yet the artifact will still be inactive. Some conditions I've seen this for are is_marriage_adult = yes and is_female = yes.
 
,

This is going to be part of the supply-and-demand system for a trade mod. There are a bunch of province-level variables and flags, most notably the generic demand variable, which are only initialized when the province is connected to a trade network and might therefore actually need them, to save on processing and memory. There are a bunch of different events that hook a province up to a trade network, and each one needs to check that these variables are initialized and, if they aren't, initialize them, before running the rest of its calculations. The initializations are long enough that I'd like to outsource them to a separate event rather than repeat them in each event, but I can just hit copy-and-paste a bunch of times if that's the only way to do it.

Ah, the correct thing here is to use Scripted Triggers and Effects. You create your own commands/conditions that you can call in your events. @LordPeter mentioned them in his reply, in case you missed it.
 
Has anyone else had problems with an artifact's "active" section? What I'm seeing is that at least some character conditions don't work correctly. They'll appear as green in the artifact's popup description in the treasury, yet the artifact will still be inactive. Some conditions I've seen this for are is_marriage_adult = yes and is_female = yes.

I've had that problem, but after unpausing the game and letting it run for a day the artifacts become active.
 
Anyone got any insight about this error?:
Code:
######## EXCEPTION: 0xC0000094 at address: 0x019D7B2B: INT DIVIDE BY ZERO
Version: CK2/branches/2_7_0_1
36394

Been trying to track it down for a week, with no luck. Crashes the game every 50 years or so, which makes it tough to pinpoint. The standard 'removing parts of the mod to see when it stops crashing' doesn't work because of the long time scale; there's too many interconnected things that tend to cause other issues if something's missing..

(By the way, not sure why the reports say 2_7_0_1 instead of x_2. Everything's up-to-date.)
 
Also, has anyone ran into an issue where a targetted decisions gets run once in a blue moon by an AI character who's already dead, even if there's 'is_alive = yes' in the from_potential?

I tried adding this as the very first effect of the decision..:
Code:
if = { limit = { FROM = { is_alive = no } }  log = "ERROR: FROM IS DEAD" }
...and it gets logged occasionally. Mostly in decisions where the FROM can die (such as suicide), but they shouldn't be dead at the beginning of the decision.

I'm starting to think that it's an engine glitch, and there's nothing that I can do about it.
 
Last edited:
Also, has anyone ran into an issue where a targetted decisions gets run once in a blue moon by an AI character who's already dead, even if there's 'is_alive = yes' in the from_potential?

I tried adding this as the very first effect of the decision..:
Code:
if = { limit = { FROM = { is_alive = no } }  log = "ERROR: FROM IS DEAD" }
...and it gets logged occasionally. Mostly in decisions where the FROM can die (such as suicide), but they shouldn't be dead at the beginning of the decision.

I'm starting to think that it's an engine glitch, and there's nothing that I can do about it.
That is very weird, I would report that as a bug as that does seem quite wrong...
 
That is very weird, I would report that as a bug as that does seem quite wrong...
Could always be some bug in my own code. There's a lot of things that even the Validator doesn't catch, and it wouldn't be the first time... For instance, trying to use conditionals that don't exist (such as 'is_prisoner' instead of 'prisoner') tends to have unusual side effects. So no point in reporting it, if nobody else has seen it happen.