Thread: How do I add a subitem?
-
Today, 02:49 #1
- Join Date
- Feb 2021
- Posts
- 426
How do I add a subitem?
in db.xml under the weapon node, I have this:
<addcrit1>
<holder name="alloowishus" owner="true" />
</addcrit1>
I want to add
<addcrit1>
<holder name="alloowishus" owner="true" />
<name type="string">Cold</name>
</addcrit1>
I tried getting the weapon node (vWeapon) and using
DB.setValue(vWeapon,"addcrit1.name","string","Cold ");
but this doesn't work. Any ideas? Thanks.
-
Today, 03:19 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 21,275
That should work as long as vWeapon is a databasenode object. If it's a string, you have to concatenate the paths first.
What is the output of vWeapon prior to that DB.setValue call?
Regards,
JPG
-
Today, 03:46 #3
- Join Date
- Feb 2021
- Posts
- 426
Here is my full code
for _,vWeapon in pairs(DB.getChildren(nodeChar, "weapons")) do
local sWeaponName = DB.getValue(vWeapon,"name","");
local sWeaponType = DB.getValue(vWeapon,"type","");
if sWeaponName == sPrimaryHand and (sWeaponType == "One-Handed Concussion" or sWeaponType == "One-Handed Slashing" or sWeaponType == "Pole Arm" or sWeaponType == "Two-Handed Weapon" or sWeaponType == "Missile Weapon" or sWeaponType == "Thrown Weapon") then
Debug.chat ("Adding " .. sAddCrit .. " table id " .. sTableID .. " to " .. sWeaponName);
DB.setValue(vWeapon,"addcrit1.name","string",sAddC rit);
end
end
-
Today, 04:13 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 21,275
Before your DB.setValue, add:
Debug.chat("PRE SET VALUE", vWeapon, sAddCrit, DB.getValue(vWeapon, "addcrit1.name"));
After your DB.setValue, add:
Debug.chat("POST SET VALUE", DB.getValue(vWeapon, "addcrit1.name"));
Regards,
JPG
-
Today, 04:27 #5
- Join Date
- Feb 2021
- Posts
- 426
Thread Information
Users Browsing this Thread
There are currently 4 users browsing this thread. (0 members and 4 guests)
Bookmarks