<Delete ... how does it work?

Serp

King
Joined
Apr 1, 2015
Messages
666
Hi,

how do I delete specific entries?

For example in promotions we have the following entries defined by the Game files:

Code:
<UnitPromotions_UnitCombats>
                <Row>
			<PromotionType>PROMOTION_VOLLEY</PromotionType>
			<UnitCombatType>UNITCOMBAT_SIEGE</UnitCombatType>
		</Row>
		<Row>
			<PromotionType>PROMOTION_MEDIC</PromotionType>
			<UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
		</Row>
</UnitPromotions_UnitCombats>
How do I delete the Recon thing with a xml file?

I tried :
Code:
<UnitPromotions_UnitCombats>
        <Delete UnitCombatType="UNITCOMBAT_RECON"/>
        <Where TYPE="PROMOTION_MEDIC"/>
</UnitPromotions_UnitCombats>
But this does not work. The effect is, that the whole xml file is not loaded. (this happens always if a error is in the xml file).

Do you know how to delete the Recon? And do you know, in which log or where I can see the line of an error in a xml file, which is not loaded? Sometimes errors in xml files are not obvious and very hard to find.


I already looked in Kaels Modder Guide, but their is no answer to a specific entry "where", only how to delete complete things =/
 
Hi,

how do I delete specific entries?

For example in promotions we have the following entries defined by the Game files:

Code:
<UnitPromotions_UnitCombats>
                <Row>
			<PromotionType>PROMOTION_VOLLEY</PromotionType>
			<UnitCombatType>UNITCOMBAT_SIEGE</UnitCombatType>
		</Row>
		<Row>
			<PromotionType>PROMOTION_MEDIC</PromotionType>
			<UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
		</Row>
</UnitPromotions_UnitCombats>
How do I delete the Recon thing with a xml file?

I tried :
Code:
<UnitPromotions_UnitCombats>
        <Delete UnitCombatType="UNITCOMBAT_RECON"/>
        <Where TYPE="PROMOTION_MEDIC"/>
</UnitPromotions_UnitCombats>
But this does not work. The effect is, that the whole xml file is not loaded. (this happens always if a error is in the xml file).

Do you know how to delete the Recon? And do you know, in which log or where I can see the line of an error in a xml file, which is not loaded? Sometimes errors in xml files are not obvious and very hard to find.


I already looked in Kaels Modder Guide, but their is no answer to a specific entry "where", only how to delete complete things =/

  1. If you have not already done so, enable error logging: whoward69's enable error logging tutorial
    The kinds of errors you are interested in (XML and SQL errors) will generally be shown in the Database.log file. This is where I always look 1st when something does not work.
  2. "Where" is implied in <Delete> unless otherwise 'overriden' in the way <Delete> is used
  3. Take a closer look at the two chunks of code you presented in your OP:
    This is correct format with correct column-name usage for the table under consideration:
    Code:
    <UnitPromotions_UnitCombats>
                    <Row>
    			<PromotionType>PROMOTION_VOLLEY</PromotionType>
    			<UnitCombatType>UNITCOMBAT_SIEGE</UnitCombatType>
    		</Row>
    		<Row>
    			<PromotionType>PROMOTION_MEDIC</PromotionType>
    			<UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
    		</Row>
    </UnitPromotions_UnitCombats>
    Is the column-name I have highlighted in red below anywhere in that 1st bit of code?
    Code:
    <UnitPromotions_UnitCombats>
            <Delete UnitCombatType="UNITCOMBAT_RECON"/>
            <Where [color="red"]TYPE[/color]="PROMOTION_MEDIC"/>
    </UnitPromotions_UnitCombats>
  4. Next, here is a sample of the method Firaxis used to Delete specific <Row>s in the table <Unit_UniqueNames>
    Code:
    <Unit_UniqueNames>
    	<Delete>
    		<UnitType>UNIT_GREAT_ADMIRAL</UnitType>
    		<UniqueName>TXT_KEY_GREAT_PERSON_MATTHEW_PERRY</UniqueName>
    	</Delete>
    </Unit_UniqueNames>
    And this is how they used <Delete> in the table <Building_ClassesNeededInCity> and <Building_FeatureYieldChanges>
    Spoiler :
    Code:
    	<Building_ClassesNeededInCity>
    		<Delete BuildingType="BUILDING_AMPHITHEATER"/>
    		<Delete BuildingType="BUILDING_POLICE_STATION"/>
    		<Delete BuildingType="BUILDING_INTELLIGENCE_AGENCY"/>
    		<Delete BuildingType="BUILDING_GRAND_TEMPLE"/>
    		<Row>
    			<BuildingType>BUILDING_AMPHITHEATER</BuildingType>
    			<BuildingClassType>BUILDINGCLASS_MONUMENT</BuildingClassType>
    		</Row>
    		<Row>
    			<BuildingType>BUILDING_POLICE_STATION</BuildingType>
    			<BuildingClassType>BUILDINGCLASS_CONSTABLE</BuildingClassType>
    		</Row>
    		<Row>
    			<BuildingType>BUILDING_INTELLIGENCE_AGENCY</BuildingType>
    			<BuildingClassType>BUILDINGCLASS_POLICE_STATION</BuildingClassType>
    		</Row>
    		<Row>
    			<BuildingType>BUILDING_GRAND_TEMPLE</BuildingType>
    			<BuildingClassType>BUILDINGCLASS_TEMPLE</BuildingClassType>
    		</Row>
    	</Building_ClassesNeededInCity>
    	<Building_FeatureYieldChanges>
    		<Delete BuildingType="BUILDING_PETRA"/>
    		<Row>
    			<BuildingType>BUILDING_PETRA</BuildingType>
    			<FeatureType>FEATURE_FLOOD_PLAINS</FeatureType>
    			<YieldType>YIELD_FOOD</YieldType>
    			<Yield>-1</Yield>
    		</Row>
    		<Row>
    			<BuildingType>BUILDING_PETRA</BuildingType>
    			<FeatureType>FEATURE_FLOOD_PLAINS</FeatureType>
    			<YieldType>YIELD_PRODUCTION</YieldType>
    			<Yield>-1</Yield>
    		</Row>
    	</Building_FeatureYieldChanges>
    1st they used <Delete> to get rid of any left-over information from loading the base-game and previous-expansion's code, and then they rebuilt the <Row> information they needed in those two tables for the Buildings or Wonders they were interested in.​
 
It's probably self-explanatory in LeeS' post (and overall a minor thing), but you can also use the shorter version that is shown in the second quote of 4 for a delete-operation that targets a specific combination instead of just deleting all entries of a Column (as Firaxis does in the example that was quoted). So...

Code:
<UnitPromotions_UnitCombats>
    <Delete>
        <PromotionType>PROMOTION_MEDIC</PromotionType>
        <UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
    </Delete>
</UnitPromotions_UnitCombats>

...can be shortened to...

Code:
<UnitPromotions_UnitCombats>
    <Delete PromotionType="PROMOTION_MEDIC" UnitCombatType="UNITCOMBAT_RECON"/>
</UnitPromotions_UnitCombats>

...and will still do the exact same thing (unless I'm horribly confusing stuff now).
 
It's probably self-explanatory in LeeS' post (and overall a minor thing), but you can also use the shorter version that is shown in the second quote of 4 for a delete-operation that targets a specific combination instead of just deleting all entries of a Column (as Firaxis does in the example that was quoted). So...

Code:
<UnitPromotions_UnitCombats>
    <Delete>
        <PromotionType>PROMOTION_MEDIC</PromotionType>
        <UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
    </Delete>
</UnitPromotions_UnitCombats>

...can be shortened to...

Code:
<UnitPromotions_UnitCombats>
    <Delete PromotionType="PROMOTION_MEDIC" UnitCombatType="UNITCOMBAT_RECON"/>
</UnitPromotions_UnitCombats>

...and will still do the exact same thing (unless I'm horribly confusing stuff now).
The second method is in game code equivalent to the first.

I tend not to edit my mod files while ModBuddy is active, I do my editing in Notepad, and I tend to copy-paste as much as possible, so I'm not sure the second is any less work to create. You just copy-paste and then do a "Find / Replace" type of function when editing your file(s) if like me you do nearly everything in Notepad or some other text editor. A "Replace" or "Replace All" occurances of "Row" with "Delete" within a text editor can vastly cut down on the amount of typing needed. You just have to remember to do these kinds of things in an orderly and organized fashion so you get all your <Delete> commands finished up within the file before you go to recreating or adding any <Row>--</Row> sets you want to place into the same file.

If you wanted to delete all the <Row>s that have UNITCOMBAT_RECON within the table <UnitPromotions_UnitCombats>, then you can just do:
Code:
<UnitPromotions_UnitCombats>
    <Delete UnitCombatType="UNITCOMBAT_RECON"/>
</UnitPromotions_UnitCombats>
I tend to also reserve the (as you phrased it) short-form of the code for these specific scenarios of using <Delete> because otherwise a clumbsy structure of the <Delete> command ends up being for me more work and troubleshooting aggravation than just showing the individual <Row>s each as their own <Delete> set. But to each their own application of the available methods.
 
I've probably not run into these issues because I've never done any projects where I really had to delete a lot of stuff - or at least I never managed to be organized enough to chunk-delete stuff. 8) I found that "deleting that one entry that got in the way" is something that's just done faster typing it manually, but of course, that's true for both methods.

With that said though, yeah, I totally see the huge benefit of being able to copy-paste a whole paragraph and then just using a replace-all function to change the tag, while there's not really that much benefit from using the shorter version. Probably a good idea to get rid of bad habits while they're still "fresh" (relatively), so thanks for explaining the reasoning behind that!
 
Back
Top Bottom