-
July 7th, 2017, 02:58 #1
Not getting right value with DB.getValue... not sure how this is possible.
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:
Code: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:
Code:<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>
Code: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
-
July 7th, 2017, 04:01 #2
I'm not a coder, but you set the value of castinitiative twice in your xml. The second time it is set to 0, so I suspect that overrides the earlier set value of 8.
Though maybe these are different entities and the lua is calling the wrong one or...?
Problems? See; How to Report Issues, Bugs & Problems
On Licensing & Distributing Community Content
Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
Note, I am not a SmiteWorks employee or representative, I'm just a user like you.
-
July 7th, 2017, 04:31 #3
You are referring to id-4? Yes, it has a 0 value but im looking at the first one, which is 3.
spell.id-00117.actions.id-00003
The scope of that bit of code doesn't (shouldnt) even know that spell.id-00117.actions.id-00004 exists.
The odd thing about all of this is the code actually works like it should. I ran it and the spells were all updated as they should be even tho the debug for nInit was always 0. I am just curious WHY it's showing that so if I see it in the future I can be aware of it.
-
July 7th, 2017, 05:21 #4
Just glancing, but I can tell you this. The code...
Code:DB.getValue(nodeAction,"castinitiative",0);
- nodeAction doesn't exist
- nodeAction isn't a databasenode
- nodeAction doesn't have a child called 'castinitiative'
- nodeAction or castinitiative aren't set to public or owned by the player client (if not the GM)
- castinitiative doesn't have a valid type
- something goes wrong in the getValue function
So something isn't matching up between nodeAction, castinitiative, and the getValue function. Try removing the the default value and see if it gives you 'nil' for nInit.
Code:DB.getValue(nodeAction,"castinitiative");
I never claimed to be sane. Besides, it's more fun this way.
-
July 7th, 2017, 06:00 #5
- debug shows that it does
- debug shows that it is
- XML code shows it
- not sure how to set this?
- xml code shows it set to number
- dunno
Your list was kinda the same list I kept going down repeatedly... that and copy/pasting the name for the value "castinitiative" thinking I had copied it wrong and was trying to get the wrong value.
I actually tried that during my testing and it did give me nil.
-
July 7th, 2017, 06:05 #6
Is the DB snip you include from a spell within the actions tab of a character sheet? Or is it a spell in the campaign data lists?
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
July 7th, 2017, 06:10 #7
Additionally, if this code has ran just one, it could have already deleted the node with DB.deleteChild(nodeAction, "castinitiative");
The FG db.xml file gets saved every 5 minutes or so. It doesn't get saved just when there are changes to the made to the database. So, I'm guessing, but maybe that code has already ran before and deleted the "castinitiative" node, but the db.xml file hasn't saved yet to reflect the up-to-date data? So you think "castinitiative" is there, but in the FG database in memory it isn't??
You can force a save by using /save in the chat window.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
July 7th, 2017, 06:49 #8
It's the actual spell record of the campaign, not a character sheet. I added a feature in my ruleset that allows you to add "actions" to a spell so when you drag/drop them onto a npc/pc they will populate in those locations.
This output was the result of a first run...when the xml was as you saw (old proper values). I was replacing it with the xml that needed conversion and issuing a /reload to force it so I could see the results.
-
July 7th, 2017, 14:28 #9
You should only ever edit any campaign data, including db.xml, when the campaign is not running. Exit the campaign, make your changes, then load the campaign. Don't use /reload as this can have unpredictable results regarding changed campaign data, it is designed to reload changes to the ruleset code.
Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
July 7th, 2017, 19:12 #10
/reload doesn't save the database to the db.xml file. You need to use /save first to do that.
I never claimed to be sane. Besides, it's more fun this way.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks