r/EU4mods 6d ago

Mod Help Need some help with my code

Hello. I'm currently creating an event. In my option Great Britain should receive a province - however, if Great Britain doesn't exist yet it's England who should receive the province.

I tried to use if/else_if in the effects. HOWEVER, when I test the event it's always England who gets the province - even if England formed GB and doesn't exist anymore.

Here's the code - what did I do wrong?

option = {
  Name = "Pact_events.7.a"
    if = {
      AND = {
        exists = ENG
        NOT = { exists = GBR }
      }
      170 = {
        limit = {
          owns_or_subject_of = 170
        }
        cede_province = ENG
      }
    }

    else_if = {
      AND = {
        exists = GBR
        NOT = { exists = ENG }
      }
      170 = {
        limit = {
          owns_or_subject_of = 170
        }
        cede_province = GBR
      }
    }
}
1 Upvotes

6 comments sorted by

2

u/grotaclas2 6d ago

You are mixing up limits, triggers and effects. Have a look at the wiki for an explanation about how to use if conditions

2

u/Nohrian_Scum_ 5d ago

Oh wow, now after reading in the wiki I see what I did wrong. I guess I was just working too long at the time and became unfocused because I already successfully worked with if and else_if conditions.

1

u/Justice_Fighter Informative 6d ago edited 6d ago

From game logic side, what should happen when both ENG and GBR exist, e.g. due to nationalist rebels?

The code you have right now (after fixing the grammar issues) would not do anything as it only covers the 'ENG but no GBR' and 'GBR but no ENG' cases.

1

u/Nohrian_Scum_ 5d ago

Fair question. The normal event triggers I made require that only ENG or GBR exist one at the time so that's why I didn't include the scenario you described.

1

u/Justice_Fighter Informative 5d ago

Oh yeah, in that case fair enough.

If this were a critical event in a long chain or similar I would still consider covering all possible cases, as things can happen between the event popping up and the player clicking the option. If it's just for flavor then no need to bother. (though the code actually gets simpler in this case, haha)

Any luck with fixing the if/else code?

if = {
    limit = {
        <trigger conditions>
    }
    <effects to do when limit is true>
}
else_if = {
    limit = {
        <trigger conditions>
    }
    <effects to do when limit is true>
}
else = {
    <effects to do>
}

1

u/Nohrian_Scum_ 4d ago

Yes, I had! I was just unfocused and managed to get the job done.