-
November 13th, 2023, 10:57 #1
- Join Date
- Aug 2019
- Location
- Australia
- Posts
- 31
How to copy an item, but put it under a different node.
In the AFF ruleset we have custom buttons to add armour and weapons, as they are saved under the <armour /> and <weapon /> XML nodes in db.xml. I've added GM buttons as can be seen in the attachment.
In the example of an armour item, the database will look like this:
Code:<root version="4.4" dataversion="20230911" release="23.11|CoreRPG:6"> <armour> <id-00001> <damage_mod type="number">0</damage_mod> <itemtype type="string">armour</itemtype> <level type="number">0</level> <name type="string">Some Armour</name> <roll1 type="number">0</roll1> <roll2 type="number">0</roll2> <roll3 type="number">0</roll3> <roll4 type="number">0</roll4> <roll5 type="number">0</roll5> <roll6 type="number">0</roll6> <roll7 type="number">0</roll7> <text type="formattedtext"> <p /> </text> </id-00001> </armour>
Code:<item> <id-00001> <action1_value type="number">0</action1_value> <consumable type="number">0</consumable> <name type="string">An Item</name> <notes type="formattedtext"> <p /> </notes> <weight type="number">0</weight> </id-00001> <id-00003> <action1_value type="number">0</action1_value> <consumable type="number">0</consumable> <count type="number">1</count> <damage_mod type="number">0</damage_mod> <itemtype type="string">armour</itemtype> <level type="number">0</level> <locked type="number">1</locked> <name type="string">Some Armour (Copy)</name> <notes type="formattedtext"> <p /> </notes> <roll1 type="number">0</roll1> <roll2 type="number">0</roll2> <roll3 type="number">0</roll3> <roll4 type="number">0</roll4> <roll5 type="number">0</roll5> <roll6 type="number">0</roll6> <roll7 type="number">0</roll7> <text type="formattedtext"> <p /> </text> <weight type="number">0</weight> </id-00003> </item>
Code:itemtype = "armour"
Code:<armour />
I know in hindsight I should have made these sub-item types but I believe I followed one of Damned's tutorials and this is where we are
Thanks in advance for any insight.
Oh, and I worked out the hard way the order of strings in the aDataMap variable is important. Make sure item is first.
-
November 13th, 2023, 19:11 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,588
It is not recommended to store multiple item types in separate locations in the database, as all the core item management features (party sheet, item transfers, etc.) are designed to be used with a single source of data. For every other ruleset out there, all the items are stored in the same location, and the type/subtype fields are used to differentiate armor and weapons. Then, special record views are used to be able to display these (which you can see in 5E/PFRPG rulesets and more). I highly recommend migrating to using a single item record type approach.
If you want to create a new item with some fields pre-filled, you would need to create the child node, get a reference to that node, and preset the data field (i.e. type/subtype). Or you can just allow them to type into type/subtype field; or provide a drop-down.
Regards,
JPG
-
November 14th, 2023, 03:00 #3
- Join Date
- Aug 2019
- Location
- Australia
- Posts
- 31
Thanks JPG. I might have to just bite the bullet and refactor.
-
November 14th, 2023, 03:58 #4
You can crack open 5E and see how the type field operates in displaying different fields based on the item type. It's a bit of staple for most rulesets I've built.
Dominic Morta
Ruleset Developer
Smiteworks
How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it
How to provide an Unity Connection issue?-Connection Issues and What to Provide
Unity Updater issue?-Updater Issues
Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained
Comcast or Cox ISP User?-Comcast XFinity and Cox Users
Have a suggestion?-Feature Request
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks