betaguru Posted March 31, 2023 Share Posted March 31, 2023 (edited) Seen a few posts here and on reddit about how to change the settings concerning traders asking the same thing, I've also seen the same code suggestions used in several Mod's going around none of which use the features xpath provides. I won't post all the code just a few snippets. First example is used to change the settings for just @id='1' <set xpath="/traders/trader_info[@id='1']/@reset_interval">1</set> <set xpath="/traders/trader_info[@id='1']/@min_inventory">40</set> <set xpath="/traders/trader_info[@id='1']/@max_inventory">100</set> <set xpath="/traders/trader_info[@id='1']/@min_items_swapped">40</set> <set xpath="/traders/trader_info[@id='1']/@max_items_swapped">100</set> <set xpath="/traders/trader_info[@id='1']/@open_time">0:00</set> <set xpath="/traders/trader_info[@id='1']/@close_time">0:00</set> Now if instead you use the features provided by xpath instead of redoing the above lines for @id='2', @id='6', @id='7' & @id='8' and having 7 lines for each ID You can have just 7 lines instead of 35 <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@reset_interval">1</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@min_inventory">50</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@max_inventory">100</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@min_items_swapped">50</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@max_items_swapped">100</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@open_time">0:00</set> <set xpath="/traders/trader_info[@id < 3 or @id > 5]/@close_time">0:00</set> For played owned/rented vending machine ie @id'3' & @id'5' instead of 4 lines for both <set xpath="/traders/trader_info[@id='3']/@reset_interval">1</set> <set xpath="/traders/trader_info[@id='3']/@allow_sell">true</set> <set xpath="/traders/trader_info[@id='5']/@reset_interval">1</set> <set xpath="/traders/trader_info[@id='5']/@allow_sell">true</set> You get the following 2 lines to cover both <set xpath="/traders/trader_info[@id='3' or @id='5']/@reset_interval">1</set> <set xpath="/traders/trader_info[@id='3' or @id='5']/@allow_sell">true</set> Or if you don't want to type it all out here you go BG's Trader Fix Edited March 31, 2023 by betaguru used reset_interval instead of settings (see edit history) Link to comment Share on other sites More sharing options...
BFT2020 Posted March 31, 2023 Share Posted March 31, 2023 Or just <set xpath="//@open_time">0:00</set> <set xpath="//@close_time">0:00</set> This will change all the trader lines in just 2 lines of codes since traders are the only entities that have open and close times. The less than and greater than functionality is only needed if they share variables, like min_inventory, and you don't want to do an universal change. Another option is to do this <set xpath="//trader_info[@open_time='6:05']/@min_inventory">20</set> This would only change the min count for traders (since they only have the open_time variable). Copy the line and throw in a NOT logic before open_time and then it would only apply to the vending machines in the world. Multiple ways to reduce lines of code if you stop and plan ahead. Link to comment Share on other sites More sharing options...
betaguru Posted April 1, 2023 Author Share Posted April 1, 2023 I've only had 7D2D since Jan 4th 2023 and still digging out info, so thanks for the info👍 I'd just all "keep trader open" mod's used were addressing every single one separately after downloading so I just rewrote it from what was being used be so it was more efficient, still need to go thru the files and dig out info as currently I don't much about the internals yet 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