Thread: Function Issue
-
December 23rd, 2021, 21:21 #1
Function Issue
I'm trying to move calculations out of the objects and into functions, but I'm having a bit of trouble.
Here, I'm trying to pass three values into the function, the character id, a value being manipulated and the name of the object whose value I need to set.
Here's what I have in the function
Code:function calculateAbilityMod(nodeChar, strMod, numCurrent) local nResult =0; if numCurrent < 10 then nResult = math.ceil((nScore - 10) / 2); elseif numCurrent > 10 then nResult = math.floor((nScore - 10) / 2); else nResult = 0; end nodeChar.getChild(strMod).setValue(nResult); return true; end
Code:function onValueChanged() --values passed> nodeChar, strMod, numCurrent local nodeChar = window.getDatabaseNode(); local strMod = "numStrengthMod"; local numCurrent = nodeChar.getChild("numStrengthCurrent").getValue(); charManager.calculateAbilityMod(nodeChar, strMod, numCurrent); end
I don't think I'm handling the strMod value properly... I need this value so the function knows which stat modifier to update...
-
December 23rd, 2021, 21:23 #2
Please provide the XML of the control anchored to the numStrengthMod DB field.
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!
-
December 23rd, 2021, 21:31 #3
-
December 23rd, 2021, 22:46 #4
above this line
Code:nodeChar.getChild(strMod).setValue(nResult);
Code:Debug.chat(nodeChar, strMod, nResult);
-
December 23rd, 2021, 23:51 #5
-
December 24th, 2021, 00:07 #6Private 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!
-
December 24th, 2021, 01:11 #7
-
December 24th, 2021, 01:22 #8
-
December 24th, 2021, 01:46 #9Code:
<id-00001> <abilitylist /> <Checkbox1 type="number">0</Checkbox1> <chkCharisma type="number">0</chkCharisma> <chkConstitution type="number">0</chkConstitution> <chkDexterity type="number">0</chkDexterity> <chkIntelligence type="number">0</chkIntelligence> <chkStrength type="number">0</chkStrength> <chkWisdom type="number">0</chkWisdom> <numCharismaCurrent type="number">10</numCharismaCurrent> <numCharismaMod type="number">0</numCharismaMod> <numCharismaScore type="number">10</numCharismaScore> <numConstitutionCurrent type="number">16</numConstitutionCurrent> <numConstitutionMod type="number">3</numConstitutionMod> <numConstitutionScore type="number">16</numConstitutionScore> <numDexterityCurrent type="number">14</numDexterityCurrent> <numDexterityMod type="number">2</numDexterityMod> <numDexterityScore type="number">14</numDexterityScore> <numExperience type="number">0</numExperience> <numFamiliarBonus type="number">0</numFamiliarBonus> <numHeight type="number">0</numHeight> <numIntelligenceCurrent type="number">8</numIntelligenceCurrent> <numIntelligenceMod type="number">-1</numIntelligenceMod> <numIntelligenceScore type="number">8</numIntelligenceScore> <numLevel type="number">1</numLevel> <numNextLevel type="number">0</numNextLevel> <numNonProficiencyBonus type="number">0</numNonProficiencyBonus> <numProficiencyBonus type="number">1</numProficiencyBonus> <numSpeed type="number">0</numSpeed> <numSpellcastingBonus type="number">0</numSpellcastingBonus> <numStrengthCurrent type="number">17</numStrengthCurrent> <numStrengthMod type="number">4</numStrengthMod> <numStrengthScore type="number">18</numStrengthScore> <numWeight type="number">0</numWeight> <numWisdomCurrent type="number">7</numWisdomCurrent> <numWisdomMod type="number">-1</numWisdomMod> <numWisdomScore type="number">7</numWisdomScore> <token type="token"></token> <txtWounds type="formattedtext"> <p /> </txtWounds> </id-00001>
-
December 24th, 2021, 02:07 #10
It looks like its working to me.
17-10/2 = 4
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks