celestian
July 7th, 2017, 02:58
I am trying to get the "castinitiative" value from a entry that I know for a fact has a number 8 in the value (see xml) but when I get it with DB.getValue it returns 0. Can anyone see what I'm doing wrong here? The use case for this is I am flipping through all spells and moving that castinitiative value to the "nodeSpell" and no longer on the nodeAction->cast type.
Here is the LUA:
function migrateSpellInitiative(nodeSpell,nodeAction)
local sName = DB.getValue(nodeSpell,"name","");
local sType = DB.getValue(nodeAction,"type","");
local nOrder = DB.getValue(nodeAction,"order",0);
local nInit = DB.getValue(nodeAction,"castinitiative",0);
Debug.console("manager_version2.lua","migrateSpellInitiative","nodeSpell",nodeSpell);
Debug.console("manager_version2.lua","migrateSpellInitiative","nodeAction",nodeAction);
Debug.console("manager_version2.lua","migrateSpellInitiative","sName",sName);
Debug.console("manager_version2.lua","migrateSpellInitiative","sType",sType);
Debug.console("manager_version2.lua","migrateSpellInitiative","nOrder",nOrder);
Debug.console("manager_version2.lua","migrateSpellInitiative","nInit",nInit);
if (sType == "cast") then
DB.deleteChild(nodeAction, "castinitiative");
if (nInit > 0) then
DB.setValue(nodeSpell,"castinitiative","number",nInit);
end
end
end
Here is the XML with the raw values/fields:
<id-00117>
<actions>
<id-00003>
<castinitiative type="number">8</castinitiative>
<order type="number">1</order>
<type type="string">cast</type>
</id-00003>
<id-00004>
<castinitiative type="number">0</castinitiative>
<heallist>
<id-00001>
<bonus type="number">3</bonus>
<dice type="dice">d8,d8,d8</dice>
</id-00001>
</heallist>
<order type="number">2</order>
<type type="string">heal</type>
</id-00004>
</actions>
<aoe type="string">1 creature</aoe>
<cast type="number">0</cast>
<castingtime type="string">8</castingtime>
<components type="string">V, S</components>
<description type="formattedtext">
<p>The <i>cure critical wounds </i>spell is a very potent version of the <i>cure light wounds </i>spell. The priest lays his hand upon a creature and heals <b>3d8+3 </b>points of damage from wounds or other damage. The spell does not affect creatures without corporeal bodies, those of extraplanar origin, or those not living.</p>
<p>The reversed spell, <i>cause critical wounds </i>, operates in the same fashion as other <i>causes wounds </i>spells, requiring a successful touch to inflict the <b>3d8+3 </b>points of damage. Caused wounds heal via the same methods as do wounds of other sorts.</p>
</description>
<duration type="string">Permanent</duration>
<level type="number">5</level>
<locked type="number">1</locked>
<memorized type="number">0</memorized>
<name type="string">Cure Critical Wounds</name>
<prepared type="number">0</prepared>
<range type="string">Touch</range>
<reversible type="number">1</reversible>
<ritual type="number">0</ritual>
<save type="string">None</save>
<school type="string">Necromancy</school>
<shortdescription type="string">Range: Touch, AoE: 1 creature, Duration: Permanent, Cast Time: 8, Save: None</shortdescription>
<source type="string">AD&D Core Rules</source>
<sphere type="string">Healing</sphere>
<type type="string">Divine</type>
</id-00117>
Here is the debug output. The value returned in nInit should be what the XML shows but it keeps returning 0.
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nodeSpell' | databasenode = { spell.id-00117 }
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nodeAction' | databasenode = { spell.id-00117.actions.id-00003 }
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'sName' | s'Cure Critical Wounds'
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'sType' | s'cast'
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nOrder' | #1
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nInit' | #0
Here is the LUA:
function migrateSpellInitiative(nodeSpell,nodeAction)
local sName = DB.getValue(nodeSpell,"name","");
local sType = DB.getValue(nodeAction,"type","");
local nOrder = DB.getValue(nodeAction,"order",0);
local nInit = DB.getValue(nodeAction,"castinitiative",0);
Debug.console("manager_version2.lua","migrateSpellInitiative","nodeSpell",nodeSpell);
Debug.console("manager_version2.lua","migrateSpellInitiative","nodeAction",nodeAction);
Debug.console("manager_version2.lua","migrateSpellInitiative","sName",sName);
Debug.console("manager_version2.lua","migrateSpellInitiative","sType",sType);
Debug.console("manager_version2.lua","migrateSpellInitiative","nOrder",nOrder);
Debug.console("manager_version2.lua","migrateSpellInitiative","nInit",nInit);
if (sType == "cast") then
DB.deleteChild(nodeAction, "castinitiative");
if (nInit > 0) then
DB.setValue(nodeSpell,"castinitiative","number",nInit);
end
end
end
Here is the XML with the raw values/fields:
<id-00117>
<actions>
<id-00003>
<castinitiative type="number">8</castinitiative>
<order type="number">1</order>
<type type="string">cast</type>
</id-00003>
<id-00004>
<castinitiative type="number">0</castinitiative>
<heallist>
<id-00001>
<bonus type="number">3</bonus>
<dice type="dice">d8,d8,d8</dice>
</id-00001>
</heallist>
<order type="number">2</order>
<type type="string">heal</type>
</id-00004>
</actions>
<aoe type="string">1 creature</aoe>
<cast type="number">0</cast>
<castingtime type="string">8</castingtime>
<components type="string">V, S</components>
<description type="formattedtext">
<p>The <i>cure critical wounds </i>spell is a very potent version of the <i>cure light wounds </i>spell. The priest lays his hand upon a creature and heals <b>3d8+3 </b>points of damage from wounds or other damage. The spell does not affect creatures without corporeal bodies, those of extraplanar origin, or those not living.</p>
<p>The reversed spell, <i>cause critical wounds </i>, operates in the same fashion as other <i>causes wounds </i>spells, requiring a successful touch to inflict the <b>3d8+3 </b>points of damage. Caused wounds heal via the same methods as do wounds of other sorts.</p>
</description>
<duration type="string">Permanent</duration>
<level type="number">5</level>
<locked type="number">1</locked>
<memorized type="number">0</memorized>
<name type="string">Cure Critical Wounds</name>
<prepared type="number">0</prepared>
<range type="string">Touch</range>
<reversible type="number">1</reversible>
<ritual type="number">0</ritual>
<save type="string">None</save>
<school type="string">Necromancy</school>
<shortdescription type="string">Range: Touch, AoE: 1 creature, Duration: Permanent, Cast Time: 8, Save: None</shortdescription>
<source type="string">AD&D Core Rules</source>
<sphere type="string">Healing</sphere>
<type type="string">Divine</type>
</id-00117>
Here is the debug output. The value returned in nInit should be what the XML shows but it keeps returning 0.
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nodeSpell' | databasenode = { spell.id-00117 }
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nodeAction' | databasenode = { spell.id-00117.actions.id-00003 }
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'sName' | s'Cure Critical Wounds'
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'sType' | s'cast'
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nOrder' | #1
Runtime Notice: s'manager_version2.lua' | s'migrateSpellInitiative' | s'nInit' | #0