sphereii Posted January 9, 2019 Author Share Posted January 9, 2019 Thank you for the reply. I look forward to that development, I already have plans, Same... distributing a custom prefab, with its custom blocks, entities, etc... would be a lot of fun, I think. Link to comment Share on other sites More sharing options...
Dimpy Posted January 9, 2019 Share Posted January 9, 2019 Can the set command replace an enitre node? for example, if I were to change <biome name="city"> <spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" /> <spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" /> <spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" /> </biome> to <biome name="city"> <spawn maxcount="10" respawndelay="0.25" time="Day" entitygroup="ZombiesAll" /> <spawn maxcount="6" respawndelay="0.5" time="Night" entitygroup="ZombiesNight" /> <spawn maxcount="1" respawndelay="0.5" time="Any" entitygroup="ZombieDogGroup" /> </biome> could I do that in a single set command, and what would be the syntax if so? Link to comment Share on other sites More sharing options...
sphereii Posted January 9, 2019 Author Share Posted January 9, 2019 Can the set command replace an enitre node? for example, if I were to change <biome name="city"> <spawn maxcount="3" respawndelay="1" time="Day" entitygroup="ZombiesAll" /> <spawn maxcount="5" respawndelay="1" time="Night" entitygroup="ZombiesNight" /> <spawn maxcount="1" respawndelay="1" time="Any" entitygroup="ZombieDogGroup" /> </biome> to <biome name="city"> <spawn maxcount="10" respawndelay="0.25" time="Day" entitygroup="ZombiesAll" /> <spawn maxcount="6" respawndelay="0.5" time="Night" entitygroup="ZombiesNight" /> <spawn maxcount="1" respawndelay="0.5" time="Any" entitygroup="ZombieDogGroup" /> </biome> could I do that in a single set command, and what would be the syntax if so? No, this would be multiple sets for each attribute you wanted to change. Alternatively, you could just remove the biome[@name=city] and append a new one. Link to comment Share on other sites More sharing options...
Dimpy Posted January 9, 2019 Share Posted January 9, 2019 Is it considered bad practice to overwrite an entire XML file? Link to comment Share on other sites More sharing options...
sphereii Posted January 9, 2019 Author Share Posted January 9, 2019 Is it considered bad practice to overwrite an entire XML file? for a shareable modlet, yes. You won't know what changes were done previously. If you were just doing an Overhaul, it'd be fine. Link to comment Share on other sites More sharing options...
Dimpy Posted January 9, 2019 Share Posted January 9, 2019 for a shareable modlet, yes. You won't know what changes were done previously. If you were just doing an Overhaul, it'd be fine. Just to be clear, when I said overwrite the XML, I meant using <remove> and then <append> Link to comment Share on other sites More sharing options...
sphereii Posted January 9, 2019 Author Share Posted January 9, 2019 Just to be clear, when I said overwrite the XML, I meant using <remove> and then <append> That's different, and totally fine I thought you were asking if you could remove and replace the entire file. Link to comment Share on other sites More sharing options...
Dimpy Posted January 9, 2019 Share Posted January 9, 2019 I just tried using the method with spawning.XML and I got the notification that it failed parsing the XML because "multiple document element was detected". I could successfully start a world, but zombies wouldn't spawn. I used Guppy's technique of exporting the resultant XML, and that looked okay. I presume I have some syntax error or my filenames aren't correct. Can you give advice on what's wrong with this this modlet?[ATTACH]27012[/ATTACH]DimpySpawn.zip Link to comment Share on other sites More sharing options...
sphereii Posted January 9, 2019 Author Share Posted January 9, 2019 You are missing your top level node. It can be anything <configs> <remove xpath="/spawning"/> <append xpath="/"> <spawning> <!-- blah blah --> </spawning> </append> </configs> Link to comment Share on other sites More sharing options...
Dimpy Posted January 9, 2019 Share Posted January 9, 2019 Tried again with your code. Got the error "Matched node cannot be appended" [ATTACH]27013[/ATTACH]DimpySpawn.zip Link to comment Share on other sites More sharing options...
Crater Creator Posted January 10, 2019 Share Posted January 10, 2019 <append xpath=""> - it also may allow us to append a value to an existing value. ( this needs testing ) example: This line could potentially add noammo to the existing value of 9mmbullet. <append xpath="/items/item/property[@class='action0']/property[@name='magazine_items' and @value='9mmbullet']/@value">,noammo</append> Forgive me for not reading the whole thread, but I just tested this and I can report it does appear to work. My mod added this code... <append xpath="/items/item[starts-with(@name,'hazmat')]/effect_group[@tiered='false']/passive_effect[@name='ElementalDamageResist']/@tags">,heat</append> ...and, using exportcurrentconfigs, I got this result... <item name="hazmatBoots"> <property name="Extends" value="hazmatClothingMaster" param1="CustomIcon" /> <property name="Tags" value="lowerbody,feet,clothing" /> <property name="EquipSlot" value="Feet" /> <property class="UMA"> <property name="Mesh" value="armor_hazmat_feet" /> <property name="Overlay0" value="armor_hazmat_boots" /> <property name="Layer" value="0" /> <property name="UISlot" value="Footwear" /> </property> <effect_group tiered="false"> <passive_effect name="ModSlots" operation="base_set" value="1" /> <passive_effect name="HypothermalResist" operation="base_add" value="6"><!--Attribute "value" replaced by: "ComSenMod"--></passive_effect> <passive_effect name="HyperthermalResist" operation="base_add" value="1" /> [color="#FF8C00"] <passive_effect name="ElementalDamageResist" operation="base_add" value="5" tags="lowerbody,feet,radiation,toxic,[b]heat[/b]" match_all_tags="true"><!--Attribute "tags" appended by: "ComSenMod"--></passive_effect> [/color] </effect_group> </item> Now it doesn't have the desired effect, mind you - I'm still figuring that out. But at least I can confirm that append can modify the script in this way. Link to comment Share on other sites More sharing options...
Malacay2k11 Posted January 10, 2019 Share Posted January 10, 2019 Tried to add a new Item to GameStart. can anyone explain my mistake ? <set xpath="/entity_classes/entity_class[@name='playerMale']/proberty[@name='ItemsOnEnterGame.GameModeSurvival']/@value">keystoneBlock,qc_welcomeMod</set> Link to comment Share on other sites More sharing options...
sphereii Posted January 10, 2019 Author Share Posted January 10, 2019 Tried to add a new Item to GameStart. can anyone explain my mistake ? <set xpath="/entity_classes/entity_class[@name='playerMale']/proberty[@name='ItemsOnEnterGame.GameModeSurvival']/@value">keystoneBlock,qc_welcomeMod</set> It's /property, not /proberty Link to comment Share on other sites More sharing options...
Malacay2k11 Posted January 10, 2019 Share Posted January 10, 2019 (edited) so simple xD but it dosen't fix the problem <set xpath="/entity_classes/entity_class[@name='playerMale']/property[@name='ItemsOnEnterGame.GameModeSurvival']/@value">keystoneBlock,qc_welcomeMod</set> Edited January 10, 2019 by Malacay2k11 (see edit history) Link to comment Share on other sites More sharing options...
Malacay2k11 Posted January 10, 2019 Share Posted January 10, 2019 Got it Link to comment Share on other sites More sharing options...
Dimpy Posted January 10, 2019 Share Posted January 10, 2019 Tried again with your[shpereii's] code. Got the error "Matched node cannot be appended" [ATTACH]27013[/ATTACH] Can someone help with this? Check the modlet for obvious errors? Link to comment Share on other sites More sharing options...
sphereii Posted January 10, 2019 Author Share Posted January 10, 2019 Can someone help with this? Check the modlet for obvious errors? try removing the first line, with <?xml in it. Link to comment Share on other sites More sharing options...
Dimpy Posted January 10, 2019 Share Posted January 10, 2019 try removing the first line, with <?xml in it. That didn't work. The error message did change though. Now it says "object reference not set to an instance of object" Link to comment Share on other sites More sharing options...
sphereii Posted January 10, 2019 Author Share Posted January 10, 2019 That didn't work. The error message did change though. Now it says "object reference not set to an instance of object" I'm not familiar with the syntax required to remove all of a file. You could try something like <remove xpath="/spawning/*" /> ... Link to comment Share on other sites More sharing options...
Dimpy Posted January 10, 2019 Share Posted January 10, 2019 <remove xpath="/spawning"/> does not delete the whole file (fine by me); Just the part that is contained in <spawning></spawning> I looked at the resultant XML from exportcurrentconfigs and on one iteration of the Append syntax, everything except the header comment was gone, so I think the issue is with the append syntax. I changed the append syntax and the code reappeared, but it wasn't the code I told it to put back in; it was the original. I presume the game will reset the XML if it finds errors. <append xpath="/spawning"/> resets it and <append xpath=""/> has everything deleted. Here is the file. [ATTACH]27029[/ATTACH] Who should I ask for help on this?DimpySpawn.zip Link to comment Share on other sites More sharing options...
Karoti Posted January 12, 2019 Share Posted January 12, 2019 The following does not appear to work, can you not remove passive_effect? <remove xpath="items/item[@name=gunPistolAdmin]/passive_effect[@name=EntityDamage]"/> Link to comment Share on other sites More sharing options...
sphereii Posted January 12, 2019 Author Share Posted January 12, 2019 The following does not appear to work, can you not remove passive_effect? <remove xpath="items/item[@name=gunPistolAdmin]/passive_effect[@name=EntityDamage]"/> missing your leading / on xpath="/items/item ? Link to comment Share on other sites More sharing options...
Karoti Posted January 14, 2019 Share Posted January 14, 2019 (edited) Thank you for the reply, but it seems the leading '/' is not mandatory, although I've now added it for completeness, it's made no difference. Just had a deeper look and it seems to be fixed, I had to reference the Effect Group also... <remove xpath="/items/item[@name=gunPistolAdmin]/effect_group[@name=Base Effects]/passive_effect[@name=EntityDamage]"/> Edited January 14, 2019 by Karoti (see edit history) Link to comment Share on other sites More sharing options...
sphereii Posted January 14, 2019 Author Share Posted January 14, 2019 Thank you for the reply, but it seems the leading '/' is not mandatory, although I've now added it for completeness, it's made no difference. Just had a deeper look and it seems to be fixed, I had to reference the Effect Group also... <remove xpath="/items/item[@name=gunPistolAdmin]/effect_group[@name=Base Effects]/passive_effect[@name=EntityDamage]"/> I am glad you got it working. XPath can be tricky with its syntax. I'll always recommend fixing the inconsistencies I find first, as it may make some corner cases start working. Link to comment Share on other sites More sharing options...
Aribo Posted January 15, 2019 Share Posted January 15, 2019 I am glad you got it working. XPath can be tricky with its syntax. I'll always recommend fixing the inconsistencies I find first, as it may make some corner cases start working. Hey Sphereii, thanks for adding in detail to the xpath modding, this is really helpful work, thank you Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now