Jump to content

usHallgrim

Members
  • Posts

    34
  • Joined

  • Last visited

usHallgrim's Achievements

Scavenger

Scavenger (2/15)

13

Reputation

  1. Me: Ah I see what you mean. Telric: [eyes roll] Sorry it took so long and I haven't tested it completely but this loads without any issues so I think I finally got it. <configs> <insertBefore xpath="/lootcontainers/lootgroup[@name='groupToolsT1']"> <lootgroup name="groupToolsT1Repair" loot_quality_template="QLTemplateT1" > <item name="meleeToolRepairT1ClawHammer"/> </lootgroup> </insertBefore> <!-- Remove all items from groupRollingToolbox01 through groupRollingToolbox03 --> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox01']/item"/> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox02']/item"/> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox03']/item"/> <!-- Append the emptied lootgroups back with the desired items valid loot_prob_template(s) are veryLow, low, medLow, med, medHigh, high --> <append xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox01']"> <!-- Line 5646 in vanilla --> <item name="foodEgg" count="2,4" loot_prob_template="high"/> <item group="groupToolsT1Wrench" loot_prob_template="low"/> <item group="groupToolsT1Repair" loot_prob_template="low"/> </append> <!-- Other toolboxes will go below --> </configs> Thanks a million Telric this was kicking my rear hard. And I think I'm sorted finally. 👍
  2. Okay I tried insertBefore and insertAfter and both fail. Here is the error and I'll provide my code below the error. Hopefully I just got the syntax wrong or something easy. I have added the line numbers (check comments in XML) from the vanilla files that I think might be relevant. The errors: 2023-11-17T10:42:55 42.842 WRN XML patch for "loot.xml" from mod "UltimateCatchAll" did not apply: <append xpath="/lootcontainers/lootgroup[@name='groupToolsT1Repair']/item" (line 8 at pos 3) 2023-11-17T10:42:55 42.871 ERR XML loader: Loading and parsing 'loot.xml' failed 2023-11-17T10:42:55 42.873 EXC lootgroup 'groupToolsT1Repair' does not exist or has not been defined before being reference by lootcontainer/lootgroup name='groupRollingToolbox01' at LootFromXml.ParseItemList (System.String _containerId, System.Collections.Generic.IEnumerable`1[T] _childNodes, System.Collections.Generic.List`1[T] _itemList, System.Int32 _minQualityBase, System.Int32 _maxQualityBase) [0x00117] in <f62c1f5c97c445c2a14e9b2f5e8c30ee>:0 at LootFromXml.LoadLootGroup (System.Xml.Linq.XElement _elementGroup) [0x0020d] in <f62c1f5c97c445c2a14e9b2f5e8c30ee>:0 at LootFromXml+<LoadLootContainers>d__1.MoveNext () [0x00081] in <f62c1f5c97c445c2a14e9b2f5e8c30ee>:0 at ThreadManager+<CoroutineWrapperWithExceptionCallback>d__51.MoveNext () [0x00044] in <f62c1f5c97c445c2a14e9b2f5e8c30ee>:0 UnityEngine.StackTraceUtility:ExtractStringFromException(Object) Log:Exception(Exception) <>c__DisplayClass52_0:<loadSingleXml>b__2(Exception) <CoroutineWrapperWithExceptionCallback>d__51:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) My code: <configs> <insertBefore xpath="/lootcontainers/lootgroup[@name='groupToolsT1']"> <!-- This group is in vanilla line 3518 --> <append xpath="/lootcontainers/lootgroup[@name='groupToolsT1Repair']"/> <!-- I TRIED ADDING THIS ATTRIBUTE TO THE GROUP via <append xpath="/lootcontainers/lootgroup[@name='groupToolsT1Repair']" loot_quality_template="QLTemplateT1"/> BUT THAT FAILED SAME ERROR --> </insertBefore> <append xpath="/lootcontainers/lootgroup[@name='groupToolsT1Repair']/item"> <!-- POINT NOW WHERE 'groupToolsT1Repair' does not exist ERRORS ARE BEING THROWN --> <item name="meleeToolRepairT1ClawHammer"/> </append> <!-- Remove all items from groupRollingToolbox01 through groupRollingToolbox03 --> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox01']/item"/> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox02']/item"/> <remove xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox03']/item"/> <!-- Append the emptied lootgroups back with the desired items valid loot_prob_template(s) are veryLow, low, medLow, med, medHigh, high --> <append xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox01']"> <!-- Line 5646 in vanilla --> <item name="foodEgg" count="2,4" loot_prob_template="high"/> <item group="groupToolsT1Wrench" loot_prob_template="low"/> <item group="groupToolsT1Repair" loot_prob_template="low"/> </append> <append xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox02']"> <item name="foodEggBoiled" count="2,4" loot_prob_template="high"/> <item name="meleeToolRepairT1ClawHammer" loot_prob_template="low"/> <item name="meleeToolSalvageT2Ratchet" loot_prob_template="low"/> </append> <append xpath="/lootcontainers/lootgroup[@name='groupRollingToolbox03']"> <item name="foodBaconAndEggs" count="2,4" loot_prob_template="high"/> <item name="meleeToolSalvageT3ImpactDriver" loot_prob_template="veryLow"/> <item name="meleeToolRepairT3Nailgun" loot_prob_template="veryLow"/> </append> </configs>
  3. Oh I agree 100% but there's years of data in the forums here that would take an extremely long time to read and some of it could be way out of date. For me the search function hasn't been very good it didn't find <set xpath=""> so I removed the <> and then it found a whole bunch of hits, but I didn't even have a clue to search for that as an answer to my question. But granted an insertBefore search reveals that term is in use and I am able to find examples by it. But the best thing was to actually read down through the whole "XPath Modding Explanation Thread" until I ran into the first insertBefore explanation (which the search doesn't take you to directly). Anyway, I'm not trying to push any AI tool, but I am using it because I can get an immediate response and if it does know the statement it usually (but not always) nails the syntax with all the /["@ nesting etc. Being able to get that help instantly is a real benefit and I've already made up 11 homegrown modlets due to that help. But as you see, it's definitely got its drawbacks. So learning to use the forums when AI fails -- which it will -- is a good combo I think. Now that I have the insertBefore examples I finally have what I need to try and create the lootgroups in the order you have been suggesting. Thank you for your help and patience. I think I got this now. I think there's nothing wrong with using both resources, one is very quick and responsive and usually nails the specific syntax your wanting to craft, and the other is much more helpful broadening and deepening one's knowledge.
  4. So, I thought I would walk through what I was trying to do: First I referenced this base xml: <lootgroup name="groupRollingToolbox03"> <!-- [Line 5645] --> <item name="meleeToolPaintTool" loot_prob_template="med"/> <item name="meleeToolWireTool" loot_prob_template="medLow"/> <item group="groupToolsT1Wrench" loot_prob_template="low"/> <item group="groupToolsT1ClawHammer" loot_prob_template="veryLow"/> <item name="resourceForgedSteel" count="1,4" loot_prob_template="veryLow"/> </lootgroup> And I noted that two of the items in there aren't just items, but also groups, so I went to look at these groups: <!-- *** Wrench_Loot [Line 3536]--> <lootgroup name="groupToolsT1Wrench" loot_quality_template="QLTemplateT1"> <item name="meleeToolSalvageT1Wrench"/> </lootgroup> <!-- *** Hammer_Loot --> <lootgroup name="groupToolsT1ClawHammer" loot_quality_template="QLTemplateT1"> <item name="meleeToolRepairT1ClawHammer"/> </lootgroup> So not to mess with the vanilla base I wanted to add new lootgroups that I could point the rolling toolboxes at: I made up the name "groupToolsT1Repair" (among others) and tried to add the claw hammer to that group. Now So I'm going to go to ChatGPT and see if I can get it to do the insertBefore syntax for me and I'll report back. Scratch that idea, I asked ChatGPT about an insertBefore statement and the response was: ME: Is there an insertbefore statement in xml? CHATGPT: No, XML itself doesn't have an insertBefore statement like you might find in some programming languages or APIs. However, when working with XML in a programming environment, you can use the programming language's XML manipulation capabilities to achieve the equivalent. For example, if you are using a language like Python with the ElementTree module, you can achieve an "insertBefore" effect using methods like insert or manipulating the list of children directly. Here's a simple example using Python's ElementTree: python Copy code import xml.etree.ElementTree as ET # Parse the XML tree = ET.parse('your_xml_file.xml') root = tree.getroot() # Find the element you want to insert before target_element = root.find('target_element') # Create a new element to insert new_element = ET.Element('new_element') new_element.text = 'Some text' # Insert the new element before the target element root.insert(root.index(target_element), new_element) # Save the modified XML tree.write('modified_xml_file.xml') This code snippet finds an element called 'target_element' in the XML and inserts a new element ('new_element') before it. Remember, the exact approach might vary depending on the programming language and XML manipulation library you are using. Be sure to consult the documentation for the specific library or tool you're working with. I'm going to have to go somewhere else for the syntax.
  5. Bless those brave souls that venture into the discordance of Discord. Not a big fan. But, I probably should go over there if that's a place to get help because I need a lot of it. 😅
  6. Yes, 100% I am trying to create that as a new lootgroup. Prior to my meddling it doesn't exist. I am trying to use append to create a new lootgroup. That might be the wrong wat to go, but that strategy works with recipes, but maybe not lootgroups? I don't know. I'm pretty sure what I need is help creating a valid lootgroup named groupToolsT1Repair. If I can just get it created, then I'm pretty sure I can reference it. This is what I had at the top of the original post, and it aligns with what you and the parser are telling me (now that you pointed it out). I just can't seem to get the lootgroup created: Acknowledged. Like I said ChatGPT often gets things wrong. Again, Telric, thank you for your time and help. I truly appreciate you trying to sort out my dunderheadedness.
  7. I am using TFP vanilla generator. Here are the settings: <MapInfo> <property name="Scale" value="1" /> <property name="HeightMapSize" value="8192,8192" /> <property name="Modes" value="Survival,SurvivalSP,SurvivalMP,Creative" /> <property name="FixedWaterLevel" value="false" /> <property name="RandomGeneratedWorld" value="true" /> <property name="GameVersion" value="Alpha.21.1.16" /> <property name="Generation.Seed" value="K" /> <property name="Generation.Towns" value="Default" /> <property name="Generation.Wilderness" value="Default" /> <property name="Generation.Lakes" value="Default" /> <property name="Generation.Rivers" value="Default" /> <property name="Generation.Cracks" value="Few" /> <property name="Generation.Craters" value="Few" /> <property name="Generation.Plains" value="10" /> <property name="Generation.Hills" value="4" /> <property name="Generation.Mountains" value="2" /> <property name="Generation.Snow" value="5" /> <property name="Generation.Forest" value="5" /> <property name="Generation.Desert" value="5" /> <property name="Generation.Wasteland" value="5" /> </MapInfo>
  8. I have to laugh at myself I just reached level 53 and it dawned on me that I haven't seen any roads connecting the towns. I'm thinking that maybe the world generator keys off of trader placements to build the roads? Not sure, but the option I was running with before was to generate the world and then go into world editor and manually delete the trader POIs.
  9. It just popped into my head to check other mods using setattribute and here are some that I found: From Gyro Helicopter by vinylplz <setattribute xpath="/vehicles/vehicle[@name='vehicleGyrocopter']/property[@class='motor0']" name='engine'>engine</setattribute> <setattribute xpath="/vehicles/vehicle[@name='vehicleGyrocopter']/property[@class='motor0']" name='engineOffPer'>.02</setattribute> From OCB Custom Map Waypoints by ocbMaurice <setattribute xpath="/controls/map_popup_sub_line/rect/sprite[@name='Icon']" name="sprite">${icon}</setattribute> and <setattribute xpath="/windows/window[@name='mapAreaEnterWaypointName']" name="depth">8</setattribute> <setattribute xpath="/windows/window[@name='mapAreaEnterWaypointName']/panel/panel/textfield" name="foregroundlayer">true</setattribute> From HUD Plus by AuroraGiggleFairy (AGF) <!--Added a line of code of the burning time to adjust the color.--> <setattribute xpath="/windows/window[@name='windowFuel']/panel[@style='header.panel']/label[@style='header.timer']" name="color">[white]</setattribute> I've fried my brain today so going to relax and tackle this again tomorrow. Now I have Telric's IIRC suggestion these working examples I am optimistic!
  10. Yes, loot.xml located in [your install paty]/7 Days To Die/Data/Config on my system, if you are on windows it's probably \7 Days To Die\Data\Config\loot.xml but more importantly if you are going to program/mod then you need to come up with tools and systems to help you locate and edit files. But it's a very bad idea to edit loot.xml directly. Instead download a simple mod, put it in /7 Days To Die/Mods then reference the structure typically you have /Mods/NameOfMod/ModInfo.xml that establishes the mod name and author etc. and then you will also have /Mods/NameOfMod/Config and that's where you put your code. If you want to update the loot table, you have to create a file called loot.xml. If you want to have a new recipe, you put it in recipes.xml. If you don't do it this way, and Steam or somehow your game gets updated, you will likely have all your work overwritten aka destroyed. You reference the vanilla files to figure out how the game does what it does, then you do your manipulations in your xml files in the ../Mods/NameOfMod/Config folder. So just a bit more info for you. In my opinion you need a good and fast way to locate files that contain the text/string you are looking for. I think Windows file manager will do it, but it seemed a bit slow if I recall correctly. There might be a handy app out there that is quicker. Next you need a text editor, a lot of Windows folks use notepad+ I think they call it. I've used Sublime but it's nagware.
  11. First and foremost. Thank You and Thank You for Your Time! I checked the logs but missed that WRN about my mod UlimateCatchAll which I knew to be the source of the problem. Next time I'll text search the mod name so hopefully don't miss it. Anyway, I'm still scratching my head on this so I'm posting my internal confusion here. I have added new recipes, items, etc. just by appending the xpath. I assumed that they are defined when appended if not already defined, otherwise all the mods I've done and all the mods I've poked around in wouldn't work. I've seen no mod with anything that stuck out like a define statement. So, I'm confused about that. I'm trying to add the lootgroup, and set it's loot_quality_template to "QLTemplateT1". The QLTemplateT1 already exists in loot.xml in vanilla I think it's defined at line 1332 and the xpath is --lootcontainers--lootqualitytemplates--lootqualitytemplate but I'm not 100% sure? But in any case I'm not updating it I'm just trying to call it as I seen in vanilla loot.xml for example at Line 2441: <lootgroup name="groupArmorT1" loot_quality_template="QLTemplateT1"> <item name="armorLeatherHood"/> <item name="armorLeatherGloves"/> <item name="armorLeatherChest"/> <item name="armorLeatherPants"/> <item name="armorLeatherBoots"/> <item name="armorIronHelmet"/> <item name="armorIronGloves"/> <item name="armorIronChest"/> <item name="armorIronLegs"/> <item name="armorIronBoots"/> </lootgroup> In my mind that kind of code defines groupArmorT1 and I don't see anywhere else in loot.xml where that text appears to be defined. So again, I am assuming XML is self-defining when you do a something=somethingelse. There's languages out there like that. So I went to ChatGPT (which makes mistakes all the time) and had this discussion: ME: In XML do objects have to be defined prior to calling them or are they self-defining for instance <lootgroup name="groupArmorT1" loot_quality_template="QLTemplateT1"> <item name="armorLeatherHood"/> <item name="armorLeatherGloves"/> <item name="armorLeatherChest"/> <item name="armorLeatherPants"/> <item name="armorLeatherBoots"/> <item name="armorIronHelmet"/> <item name="armorIronGloves"/> <item name="armorIronChest"/> <item name="armorIronLegs"/> <item name="armorIronBoots"/> </lootgroup> is that defining groupArmorT1? CHATGPT: In XML, elements can be defined and used in a document without a specific order. The XML document is hierarchical, and elements can reference each other without being declared in a certain order, as long as the references are valid within the document structure. In your example: <lootgroup name="groupArmorT1" loot_quality_template="QLTemplateT1"> <!-- Items listed here --> </lootgroup> The <lootgroup> element with the name attribute "groupArmorT1" is defining a loot group named "groupArmorT1." Within this element, there are child elements such as <item> that specify items belonging to this loot group. The order of appearance in the XML document doesn't necessarily dictate the order of definition or usage. Each element is self-contained and carries its attributes and content. As long as the XML is well-formed and follows the rules of the XML schema (if any), it should be valid. I also asked CHATGPT about <setattribute> and it says " as of my last knowledge update in January 2022, there isn't a standard XML element called <setattribute>. Modifying attributes in XML typically involves finding the specific element using XPath and then using methods or functions provided by the XML processing library or tool you are using." So maybe there is a library or something that uses it and I was hoping you might know where I need to go to learn about it?
  12. What I did was change it so that you instead of crafting out 1 clay lump for every 4 clay that had previously been smelted so that I get 1 clay lump for every 1 clay in the forge. I removed the old recipe and here is the new recipe: <!-- * * * * * * * * * * * * forge-emptying recipes: base game has it that you don't get a 1:1 return, this fixes that * * * * * * * * * * * * --> <recipe name="resourceClayLump" count="1" material_based="true" craft_area="forge" is_trackable="false" craft_time="1" craft_exp_gain="0" always_unlocked="true" use_ingredient_modifier="false"> <ingredient name="unit_clay" count="1"/> <!-- Previously the count was count-"4"--> </recipe> I also changed the other recipes where the ratio of return isn't 1:1.
  13. Or I just got annoyed in game because I wanted to move my forge but was going to lose 3 clay for every 1 that I had previously smelted. I'm just going to put the clay back in so why can't I just move the forge with the clay in it. Well, I didn't know if I could figure that out quickly but I thought I could figure out how to change the ratio to 1 clay smelted = 1 clay returned. So I did that in about 10 minutes. But the better solution would be the ability to move forges with smelting in them but I don't know if that's possible via XML editing alone.
  14. How about we do this > you know how when you start you are hunting for a grill, well let's make it so you can craft a grill from scrap iron. That makes sense bc all you need to do to grill meat is to suspend it over a fire with the heat being distributed by the metal. You can do that with rebar, chain link, all sorts of iron/steel scrap. Then if we get that working let's try to make it so cooking with the improvised grill takes longer. So we still want to find a grill, but we can sort of get by with a makeshift one until we find a grill. Or we can just make it so grills are much more likely to spawn in ovens and BBQs. I don't know about you but can't remember the last time I looked inside an oven or a bbq and didn't find a grill rack.
×
×
  • Create New...