【发布时间】:2023-01-13 08:15:02
【问题描述】:
开始, 我正在尝试调整我为游戏创建的模组(7 Days To Die) 我真的没有很多 XML 修改经验。但我让它做我想做的事。
但是,我不想遍历列表中的每个项目而必须调整项目的值。
XML 文件示例:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item name="ammo9mmBulletBall">
<property name="Tags" value="ammo"/>
<property name="DisplayType" value="ammoBullet"/>
<property name="HoldType" value="45"/>
<property name="Meshfile" value="#Other/Items?Misc/sackPrefab.prefab"/>
<property name="DropMeshfile" value="#Other/Items?Misc/sack_droppedPrefab.prefab"/>
<property name="Material" value="Mbrass"/>
<property name="MeltTimePerUnit" value=".4"/>
<property name="Stacknumber" value="300"/> <!-- STK ammo high -->
<property name="EconomicValue" value="9"/>
<property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"/>
<effect_group name="ammo9mmBulletBall" tiered="false">
<passive_effect name="EntityDamage" operation="base_set" value="32" tags="perkGunslinger,9mmGun"/>
<passive_effect name="BlockDamage" operation="base_set" value="6" tags="perkGunslinger"/>
<passive_effect name="DamageModifier" operation="perc_add" value="-.8" tags="earth"/>
<passive_effect name="DamageModifier" operation="perc_add" value="2" tags="wood"/>
</effect_group>
</item>
</items>
mod 文件的示例:
<?xml version="1.0" encoding="utf-8"?>
<configs>
<!-- * * * * * * * * * * ammunition / arrows / bolts / fuel * * * * * * * * * * -->
<set xpath="/items/item[starts-with(@name, 'ammo')]/property[@name='Stacknumber']/@value">500</set>
我的问题是,XML 文档中还有其他一些我不想更改的以“ammo”开头的项目。
我试图找到有关在 xpath 中出现异常的信息,例如:
<set xpath="/items/item[starts-with(@name, 'ammo'[not(@name, 'ammoBundle')])]/property[@name='Stacknumber']/@value">500</set>
然而这显然不起作用。 有没有办法做到这一点?还是我必须坚持手动编辑每个值?
我调查的另一种选择是,它是否属于“弹药/武器、弹药、远程武器”组 但我也找不到相关信息。
如果有人可以帮助我,那就太好了。
编辑: 我能够实现我所追求的一部分:
<set xpath="/items/item[starts-with(@name, 'ammo') and not(contains(@name, 'Bundle'))]/property[@name='Stacknumber']/@value">500</set>
但是,我仍在尝试根据已设置的属性值,根据使用上述方法找到的项目更改属性值:<property name="Group" value="Ammo/Weapons,Ammo,Ranged Weapons"
因此,如果项目具有上面列出的属性值,它们将调整其“Stacknumber”属性值。
不确定这是否可能。
编辑:进一步的例子 所以这只是项目本身,每行没有属性。
Example of what I want to include
<item name="ammo9mmBulletBall">
<item name="ammo9mmBulletHP">
<item name="ammo9mmBulletAP">
<item name="ammo44MagnumBulletBall">
<item name="ammo44MagnumBulletHP">
<item name="ammo44MagnumBulletAP">
<item name="ammoDartIron">
<item name="ammoShotgunBreachingSlug">
Example of what I want to exclude
<item name="ammoJunkTurretRegular">
<item name="ammoJunkTurretShell">
<item name="ammoJunkTurretAP">
<item name="ammoBundleMaster">
<item name="ammoBundleJunkTurretRegular">
<item name="ammoBundleJunkTurretShell">
<item name="ammoGasCanBundle">
<item name="ammoArrowFlamingSchematic">
<item name="ammoCrossbowBoltExplodingSchematic">
<item name="ammoGasCanSchematic">
<item name="ammoProjectileZombieVomit">
【问题讨论】: