Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logical operators trap warnings #143

Open
HiddeLekanne opened this issue Oct 11, 2024 · 4 comments
Open

Logical operators trap warnings #143

HiddeLekanne opened this issue Oct 11, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@HiddeLekanne
Copy link
Contributor

In vic3 (and I suspect in other games) if you scope inside a logical operate scope (such as OR) it will default back to AND. A somewhat common mistake I see is this:

Where the modder wants to do a scope switch, but tries to do it inside the logical operator instead of the other way around.

In the case of a single object it is clearly a mistake. So that is easy to solve.

OR = {
     c:GER = {
         gdp >= 10000
         total_population >= 800000
         ...
     }
}

However, there are legimate uses of objects inside logical operators, clearly when the scope within has just a single item:

OR = {
     c:GER = {
         gdp >= 10000
     }
     always = yes
}

But unclear when there appears to be a use for the OR.

OR = {
     c:GER = {
         gdp >= 10000
         total_population >= 800000
     }
     always = yes
}

So I don't know if that one is solvable except by forcing the modder to be pendantic and add another AND inside.

OR = {
     c:GER = {
         AND = {
              gdp >= 10000
              total_population >= 800000
         }
     }
     always = yes
}
@dragon-archer
Copy link
Contributor

dragon-archer commented Oct 12, 2024

I suppose this shouldn't generate any warning, as any opening scope under trigger context includes an implicit AND, and all paradox games (not only CK3 or Vic3 but also EU4 and so on) has the same behavior.

And, if you DO want to do a scope switch, you can either swap the scope and logic operate scope, or add another logic operate scope, e.g.

c:GER = {
     OR = {
          gdp >= 10000
          total_population >= 800000
     }
}

or

OR = {
     c:GER = {
          OR = {
               gdp >= 10000
               total_population >= 800000
          }
     }
     c:AUS = { gdp <= 10000 }
}

@amtep
Copy link
Owner

amtep commented Oct 12, 2024

I think this can be covered under a more general warning about an OR with only one item in it. Your first example would trigger such a warning. I don't think the other example is clear enough to merit a warning; it could easily be the intended code.

An OR (or an AND) with only one item in it is a minor performance issue and might indicate there is a bug there because of an uncompleted thought. Perhaps a warning at untidy level.

@HiddeLekanne
Copy link
Contributor Author

@amtep I am confused, is there currently a one item rule? If so, the current tool doesn't detect this code from vanilla when we added it to our mod. This should trigger the one item in OR right?

OR = {
        owner = {
		has_law = law_type:law_regulatory_bodies
		has_law = law_type:law_worker_protections
	}
}

@amtep
Copy link
Owner

amtep commented Oct 12, 2024

Yes I meant we could add one :)

@amtep amtep added the enhancement New feature or request label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants