.modinfo Criteria for Configuration Values

joshmanisdabomb

Chieftain
Joined
Feb 27, 2017
Messages
1
I'd like my SQL file to update the database only when the user has picked a value from my drop down box, which I've added under the Advanced Setup screen.

I've been trying for ages to use the criteria section provided in the ModBuddy, but I have no idea what keys and values need to go where. It's not very well explained.

Here's my InGameActions section in my .modinfo, where the SQL runs perfectly fine without the criteria:
Code:
  <InGameActions>
    <UpdateDatabase id="TYTUpdateDatabaseT025">
      <Criteria>TYTCriteriaTech025</Criteria>
      <File>SQLChanges/TYTT025.sql</File>
    </UpdateDatabase>
  </InGameActions>

Here's the drop down I have in the GameData:
Code:
<GameData>
    <Parameters>
        <Row ParameterId="TechnologyCostBase" Name="LOC_COST_BASE_TECH_NAME" Description="LOC_COST_BASE_TECH_DESCRIPTION" Domain="TechnologyCostBaseDom" DefaultValue="COST_BASE_TECH_X1" ConfigurationGroup="Game" ConfigurationId="COST_BASE_TECH" Hash="0" GroupId="AdvancedOptions" SortIndex="100"/>
    </Parameters>
    <DomainValues>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X025" Name="LOC_COST_BASE_X025_NAME" Description="LOC_COST_BASE_TECH_X025_DESCRIPTION" SortIndex="25"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X05" Name="LOC_COST_BASE_X05_NAME" Description="LOC_COST_BASE_TECH_X05_DESCRIPTION" SortIndex="50"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X075" Name="LOC_COST_BASE_X075_NAME" Description="LOC_COST_BASE_TECH_X075_DESCRIPTION" SortIndex="75"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X1" Name="LOC_COST_BASE_X1_NAME" Description="LOC_COST_BASE_TECH_X1_DESCRIPTION" SortIndex="100"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X125" Name="LOC_COST_BASE_X125_NAME" Description="LOC_COST_BASE_TECH_X125_DESCRIPTION" SortIndex="125"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X15" Name="LOC_COST_BASE_X15_NAME" Description="LOC_COST_BASE_TECH_X15_DESCRIPTION" SortIndex="150"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X175" Name="LOC_COST_BASE_X175_NAME" Description="LOC_COST_BASE_TECH_X175_DESCRIPTION" SortIndex="175"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X2" Name="LOC_COST_BASE_X2_NAME" Description="LOC_COST_BASE_TECH_X2_DESCRIPTION" SortIndex="200"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X25" Name="LOC_COST_BASE_X25_NAME" Description="LOC_COST_BASE_TECH_X25_DESCRIPTION" SortIndex="250"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X3" Name="LOC_COST_BASE_X3_NAME" Description="LOC_COST_BASE_TECH_X3_DESCRIPTION" SortIndex="300"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X35" Name="LOC_COST_BASE_X35_NAME" Description="LOC_COST_BASE_TECH_X35_DESCRIPTION" SortIndex="350"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X4" Name="LOC_COST_BASE_X4_NAME" Description="LOC_COST_BASE_TECH_X4_DESCRIPTION" SortIndex="400"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X45" Name="LOC_COST_BASE_X45_NAME" Description="LOC_COST_BASE_TECH_X45_DESCRIPTION" SortIndex="450"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X5" Name="LOC_COST_BASE_X5_NAME" Description="LOC_COST_BASE_TECH_X5_DESCRIPTION" SortIndex="500"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X6" Name="LOC_COST_BASE_X6_NAME" Description="LOC_COST_BASE_TECH_X6_DESCRIPTION" SortIndex="600"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X7" Name="LOC_COST_BASE_X7_NAME" Description="LOC_COST_BASE_TECH_X7_DESCRIPTION" SortIndex="700"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X8" Name="LOC_COST_BASE_X8_NAME" Description="LOC_COST_BASE_TECH_X8_DESCRIPTION" SortIndex="800"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X9" Name="LOC_COST_BASE_X9_NAME" Description="LOC_COST_BASE_TECH_X9_DESCRIPTION" SortIndex="900"/>
        <Row Domain="TechnologyCostBaseDom" Value="COST_BASE_TECH_X10" Name="LOC_COST_BASE_X10_NAME" Description="LOC_COST_BASE_TECH_X10_DESCRIPTION" SortIndex="1000"/>
    </DomainValues>
</GameData>

And going back to the .modinfo file, here is various attempts of criteria I've been using:
Code:
  <ActionCriteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueContains>
        <COST_BASE_TECH>COST_BASE_TECH_X025</COST_BASE_TECH>
      </ConfigurationValueContains>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueContains>
        <COST_BASE_TECH>x0.25 Base Cost</COST_BASE_TECH>
      </ConfigurationValueContains>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueContains>
        <TechnologyCostBase>COST_BASE_TECH_X025</TechnologyCostBase>
      </ConfigurationValueContains>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueContains>
        <TechnologyCostBase>x0.25 Base Cost</TechnologyCostBase>
      </ConfigurationValueContains>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueMatches>
        <COST_BASE_TECH>COST_BASE_TECH_X025</COST_BASE_TECH>
      </ConfigurationValueMatches>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueMatches>
        <COST_BASE_TECH>x0.25 Base Cost</COST_BASE_TECH>
      </ConfigurationValueMatches>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueMatches>
        <TechnologyCostBase>COST_BASE_TECH_X025</TechnologyCostBase>
      </ConfigurationValueMatches>
    </Criteria>
    <Criteria id="TYTCriteriaTech025">
      <ConfigurationValueMatches>
        <TechnologyCostBase>x0.25 Base Cost</TechnologyCostBase>
      </ConfigurationValueMatches>
    </Criteria>
  </ActionCriteria>

Of course, only one of these were in there at one time, I've just been swapping them in and out.
Also, 'x0.25 Base Cost' is just a localized version of 'COST_BASE_TECH_X025', because I didn't know what else to try.

If someone could show me what I'm doing wrong or just explain how to use criteria properly, it would be greatly appreciated.
 
Wasn't sure if I should start a new thread, but I've been running into a similar problem as well, if anyone's found a solution. I've tried a number of criteria arguments, but nothing's worked for me yet.
I've got this part correct I think, from my config:
Code:
<Parameters>
        <Row ParameterId="AltSpanishNames" Name="Use Alternate Spanish Names" Description="Use Alternate Spanish Names" Domain="bool" DefaultValue="1" ConfigurationGroup="Game" ConfigurationId="AltSpanishNames" GroupId="MapOptions" SortIndex="1">
    </Parameters>
It's the Criteria part that's the problem, I believe. I've tried the following attempts (and some other weird ones out of desperation), in my modinfo file:
Code:
<Criteria id="AltSpanishCheck">
      <GameConfiguration>AltSpanishNames::True</GameConfiguration>
</Criteria>
<Criteria id="AltSpanishCheck">
      <Parameters>AltSpanishNames::True</Parameters>
</Criteria>
<Criteria id="AltSpanishCheck">
      <GameConfiguration>
              <ParameterId>AltSpanishNames</ParameterId>
              <Value>1</Value>
      </GameConfiguration>
</Criteria>
<Criteria id="AltSpanishCheck">
      <GameConfiguration>AltSpanishNames::1</GameConfiguration>
</Criteria>
<Criteria id="AltSpanishCheck">
      <Parameters>AltSpanishNames::1</Parameters>
</Criteria>
<Criteria id="AltSpanishCheck">
      <GameConfiguration>
          <Parameters>
              <ParameterId>AltSpanishNames</ParameterId>
              <Value>1</Value>
          </Parameters>
      </GameConfiguration>
</Criteria>

So far nothing has returned true; if anyone has any ideas or workarounds (I'm trying to stay away from using rulesets if at all possible), I'd be greatly appreciative!
 
I've mostly been basing my attempts off of looking at what Gedemon has done for the YNAMP mod. The parameters in that mod are enabled through the Advanced Options screen; they affect changes through lua though, which is where I get a bit lost trying to figure his code out. With the code I've tried, the box shows up in the Advanced Options screen and can be toggled, but I can't actually get it to affect what I want yet.
 
Thx, I will look into YNAMP then and try to understand how he did it. I also would like to use this mechanism.

EDIT.
Checked it. And I don't see any 'Criteria' tags in .modinfo.
There's Config.xml that defines parameters for Advanced Options screen and then .lua scripts take them to generate maps. I don't see any impact on components.
 
Last edited:
[EDIT] **This might not actually be working properly, as I've seen instances where the criteria either errors, or is simply ignored*** [/EDIT]

I've been struggling with this too, and have finally just managed to get it to work.

Added the following to my mod's config.xml (loaded via and UpdateDatabase Front End Action) to get a checkbox in the advanced set-up screen:

Code:
<GameData>
    <Parameters>
        <Row ParameterId="SGP_USE_TECHRULES" Name="Use Alternate Tech and Civic Rules" Description="Load the alternate rules for Techs and Civics"
            Domain="bool" DefaultValue="1" ConfigurationGroup="Game" ConfigurationId="SGP_USE_TECHRULES" GroupId="GameOptions" SortIndex="1000" />
    </Parameters>
</GameData>

In ModBuddy, I then added a criteria to one of my In-Game Actions, this added the following to my modinfo:

Code:
  <ActionCriteria>
    <Criteria id="SGP_CRITERIA_TECHRULES">
      <ConfigurationValueMatches>
        <SGP_USE_TECHRULES>1</SGP_USE_TECHRULES>
      </ConfigurationValueMatches>
    </Criteria>
  </ActionCriteria>

And when ModBuddy generated the modinfo, it added the criteria to the action like this:

Code:
    <UpdateDatabase id="SGP_TECHRULES">
      <Criteria>SGP_CRITERIA_TECHRULES</Criteria>
      <File>Assets/Sql/SlowerTechRules.sql</File>
      <File>Assets/Sql/TechRules.sql</File>
    </UpdateDatabase>

Which doesn't work! So I manually edited the modinfo to this:

Code:
    <UpdateDatabase id="SGP_TECHRULES" Criteria="SGP_CRITERIA_TECHRULES">
      <File>Assets/Sql/SlowerTechRules.sql</File>
      <File>Assets/Sql/TechRules.sql</File>
    </UpdateDatabase>

And now it works.
 
Last edited:
Yes - toggled by the advanced set-up screen check-box. What I couldn't figure out was the difference between 'ParameterId' and 'ConfigurationId', it didn't seem to work when these were different. So I just used the same ID for both of them.

I haven't tried it with a drop-down yet. Will give it a go later today.
 
Awesome! Just tried it out on my end and it works perfectly. Thank you so much, StormingRomans!
 
Glad I could help ... I can relate to the frustration with getting it to work.

Just for reference, I've tried it with drop-downs by changing my config.xml to the following:

Code:
<GameData>
    <Parameters>
        <Row ParameterId="SGP_USE_TECHRULES" Name="Use Alternate Tech and Civic Rules" Description="Load the alternate rules for Techs and Civics"
            Domain="UseTechRules" DefaultValue="0" ConfigurationGroup="Game" ConfigurationId="SGP_USE_TECHRULES" GroupId="GameOptions" SortIndex="1000" />
    </Parameters>

    <DomainValues>
        <Row Domain="UseTechRules" Value="1" Name="Yes" Description="Yes" SortIndex="10"/>
        <Row Domain="UseTechRules" Value="0" Name="No" Description="Yes" SortIndex="20"/>
    </DomainValues>
</GameData>

Everything else was the same as in my earlier post. [EDIT] Works perfectly. ... spoke to soon :(
 
Last edited:
Everything else was the same as in my earlier post. Works perfectly.
What happens when you choose '0' in Advanced Options? Did you check it?
Because I did the above and the SQLs are executed no matter what I choose in drop-down list. Like the 'Criteria' parameter was ignored at all.
 
I think this mechanism simply does not work.
I have the following situation: 3 values and 3 scripts. Depending on which I choose, I want to run a specific script.
Parameters work in Advanced Section and they are passed to the game - this I confirmed.
But Criteria checking in .modinfo - not working.
If I use "Criteria"="xxx" then ALL scripts are executed.
If I use <Criteria>xxx</Criteria> (which auto-generated by ModBuddy), none is executed, no matter what I choose in options.

EDIT. But I can also confirm that the game is doing something when there's tag <Criteria>. I've got errors in modding.log:
[290682.584] ERROR: Error checking criteria, malformed?
[290682.585] ERROR: Error checking criteria, malformed?
[290682.585] ERROR: Error checking criteria, malformed?
 
You could be right - at least for 'ConfigurationValueMatches' criteria. It looks like even the checkboxes aren't working properly either - despite the fact it looked like they were.

I've tried it with LeaderPlayable, as per the Australia DLC, and can get that to work:

Code:
    <ActionCriteria>
        <Criteria id="xxx">
            <LeaderPlayable>StandardPlayers::LEADER_JOHN_CURTIN</LeaderPlayable>
        </Criteria>
    </ActionCriteria>

SQL will run - no errors in log.

Code:
    <ActionCriteria>
        <Criteria id="xxx">
            <LeaderPlayable>StandardPlayers::LEADER_XYZ</LeaderPlayable>
        </Criteria>
    </ActionCriteria>

SQL will not run - no errors in log.

This was both with <Criteria>xxx</Criteria> and criteria="xxx" (note the lowercase, it seems to make a difference! Which would make sense for XML).

I have some more time tomorrow, so I'll keep trying - I want to use it in my mod too.
 
You could be right - at least for 'ConfigurationValueMatches' criteria. It looks like even the checkboxes aren't working properly either - despite the fact it looked like they were.

I've tried it with LeaderPlayable, as per the Australia DLC, and can get that to work:

Code:
    <ActionCriteria>
        <Criteria id="xxx">
            <LeaderPlayable>StandardPlayers::LEADER_JOHN_CURTIN</LeaderPlayable>
        </Criteria>
    </ActionCriteria>

SQL will run - no errors in log.

Code:
    <ActionCriteria>
        <Criteria id="xxx">
            <LeaderPlayable>StandardPlayers::LEADER_XYZ</LeaderPlayable>
        </Criteria>
    </ActionCriteria>

SQL will not run - no errors in log.

This was both with <Criteria>xxx</Criteria> and criteria="xxx" (note the lowercase, it seems to make a difference! Which would make sense for XML).

I have some more time tomorrow, so I'll keep trying - I want to use it in my mod too.

How does this actually work? I tried to use the first bit, but it seems to always enable, even if the Australia DLC is disabled and the UpdateDatabase component is properly tagged with criteria="xxx".

I'm trying to use this to make some files only load if the proper DLC is enabled--which I assume is what that Criteria is for (correct me if I'm wrong), but I'm coming up empty on how to do that.
 
I actually don't think it does work .. at least reliably. Sometimes it appeared to work, and other times it quite clearly didn't do anything. I spent hours trying to figure out what was going on, and in the end gave up as there was other stuff I wanted to work on. At some point I'll come back to it and try again, as I'm getting to the point where I need to detect if certain mods are enabled before I make DB changes.

I was actually trying to use it to make some building changes only if your Wondrous Wonders mod was not enabled :)
 
Well, there's an easy workaround for that. You simply choose an object from the mod that is unique for it and add 'exists/not exists' clauses to sql statements. In some cases it's even better as it allows to react differently for different objects in the mod. But if you need just checking if the mod is not loaded, simple 'not exists' will do.
 
Well, there's an easy workaround for that. You simply choose an object from the mod that is unique for it and add 'exists/not exists' clauses to sql statements. In some cases it's even better as it allows to react differently for different objects in the mod. But if you need just checking if the mod is not loaded, simple 'not exists' will do.

My SQL knowledge is still a bit rough. I do sorta know how to do this, but it takes up a lot of space. It's what I'm doing for now, was just hoping there was a solution that'd take up less lines of code. Oh well!
 
Back
Top Bottom