View Full Version : How do I add a subitem?
alloowishus
November 22nd, 2024, 01:49
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.
Moon Wizard
November 22nd, 2024, 02:19
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
alloowishus
November 22nd, 2024, 02:46
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
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",sAddCrit);
end
end
Moon Wizard
November 22nd, 2024, 03:13
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
alloowishus
November 22nd, 2024, 03:27
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
Ok, i figured it out, I was looping over the wrong node, I should have using the inventory node. Thanks!
Powered by vBulletin® Version 4.2.1 Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.