Stumped: What are the triggers for "Recursive node event or call terminated"
EDIT:
I'M SORRY...
So, I deleted the character and did it again to document entire "path" and found that.. it worked. Completely.
Huh?
NO IDEA how I got it fibered - but of course, how I work is create a char then add code - do stuff, reload, test, review, add logging, test, remove/add code, test again, etc.
Maybe somehow?? I got in some state. But fresh - no happening. Will need to keep eye open to see if see how this can happen. Anyhow, not deleting the text in case I find it happen again - but no need to waste time reading this unless curious.
------------------------------------------
I finished encoding the AddClass and addRace along with the rules regarding max levels and max levels for class/race and whether changing at start (mistake/mind change) and logging warnings if changed later - all sorts of "fun" things ;). [What can I say, I like thinking about corner conditions]
I get what Recursion is NORMALLY. Something calls the same method in a chain. I understand the recursion might be tricker than something as obvious as you calling doFOO() which calls onFOOChanged() which called doY() which calls onFooChange() etc. But I am not sure what the recursion is here. I know it is likely this (long as it may be) is not sufficient to point out the issue, but I am hoping in Lua or FG there is something more experienced folk know to watch out for on these event handlers that can cause issue. For now, will look at doing it a different way - the way I am doing it now is because I copied code and modified it keeping the general structure - I may need to change the paths or handlers to get around this until I understand what I did wrong.
Tracing the code:
I got to the part where now on classLevelIUpdate, I set thac0 control. I do so via:
Code:
...
nThac0 = ClassCommon.class_level_thac0[sClassID][nLevel]
Debug.console("nTHAC0=", nThac0)
DB.setValue(nodeChar, "thac0", "number", nThac0)
(Commenting out setValue() call results in no recursion warning logging.)
We got to the above method addClassLevel() via:
1. Player drags from Classes dialog "Fighter" to the Character sheet that already had levels of Fighter and race = human.
2. onDrop() from record_char_more.xml is triggered. Inside it:
Code:
...
local nodeChar = getDatabaseNode()
if StringManager.contains({"pcclass"}, sClass) then
CharacterManagerSWWB.addClassDB(nodeChar, sClass, sRecord)
return true
3. In manage_char_sw.lua the method addClassDB() is called:
Code:
function addClassLevel(nodeChar, sClass, sRecord)
Debug.console(nodeChar, sClass, sRecord)
local sClassID = NodeUtils.getLeafNameFromRecord(sRecord)
local nLevel = DB.getValue(nodeChar, "pcclasslevel")
-- Existing race, if any.
local _, sCurrentPCRaceRecord = DB.getValue(nodeChar, "pcracelink")
local sRaceID = NodeUtils.getLeafNameFromRecord(sCurrentPCRaceRecord)
local aAdvancementTable = ClassCommon.class_level_advancement[sClassID]
local nCurrentLevelXPNeeded = aAdvancementTable[nLevel]
local nNextLevelXPNeeded = -1
local nMaxLevel = getMaxLevelAllowed(sClassID, sRaceID)
nLevel = nLevel + 1
if nLevel <= nMaxLevel then
nNextLevelXPNeeded = aAdvancementTable[nLevel]
end
nThac0 = ClassCommon.class_level_thac0[sClassID][nLevel]
Debug.console("nTHAC0=", nThac0)
DB.setValue(nodeChar, "thac0", "number", nThac0)
end
...
-- Full method above, the "-1" value was set by me in prep to treat being at "max level" differently but I didn't get to try it or decide if will do it that way - the recursion needed to be addressed first.
4. PRESUMABLY, I expected the setValue above to trigger onValueChanged below in record_char_more.xml file. BUT I do not see that log message "thac0 - onValueChanged" in log...?
Code:
...
<!-- The thac0 field is tied to descending AC option. -->
<number_ctlink name="thac0">
<anchored to="combatframe" position="insidetopright" offset="15,91" />
<tooltip textres="tooltip_thac0" />
<script>
function onInit()
setValue(Character.defaultTHAC0())
end
function onValueChanged()
Debug.console("thac0 - onValueChanged")
end
</script>
</number_ctlink>
...
The log of the issue:
Code:
Runtime Notice: Reloading ruleset
Runtime Notice: s'aMajor: ' | { s'CoreRPG' = #4, s'MoreCore' = #1 } | s' aMinor: ' | { s'CoreRPG' = #0, s'MoreCore' = #58 }
Runtime Notice: s'onInit: registerResultHandler'
Runtime Notice: s'onInit: '
Runtime Notice: s'drag1: ' | dragdata = { type = s'shortcut', desc = s'Classe: Fighter', #slots = #1, slot = #1, string = s'', num = #0, dice = { }, shortcut = { pcclass, referencepcclass.fighter@MCSWWB }, token = { prototype = , instance = }, custom = nil }
Runtime Notice: s'draginfo: ' | dragdata = { type = s'shortcut', desc = s'Classe: Fighter', #slots = #1, slot = #1, string = s'', num = #0, dice = { }, shortcut = { pcclass, referencepcclass.fighter@MCSWWB }, token = { prototype = , instance = }, custom = nil }
Runtime Notice: s'onDrop: ' | fn
Runtime Notice: s'sClass: ' | s'pcclass'
Runtime Notice: s'sRecord: ' | s'referencepcclass.fighter@MCSWWB'
Runtime Notice: s'getDatabaseNode(): ' | databasenode = { charsheet.id-00030 }
Runtime Notice: s'DB.getValue: ' | s'Fighter'
Runtime Notice: s'getDescription: ' | s'Classe: Fighter'
Runtime Notice: databasenode = { charsheet.id-00030 } | s'pcclass' | s'referencepcclass.fighter@MCSWWB'
Runtime Notice: s'11111'
Runtime Notice: databasenode = { charsheet.id-00030 } | s'Fighter' | s'referencepcclass.fighter@MCSWWB'
Runtime Notice: s'nTHAC0=' | #14
Script Warning: setValue: Recursive node event or call terminated (charsheet.id-00030.thac0)
Runtime Notice: s'333333'
* As an aside, I've been wondering where the Debug.console log above of "Runtime Notice: s'getDescription: ' | s'Classe: Fighter'"
- It has to be in CoreRPG, MoreCore or my SWWB extension but I cannot find it. I am not sure if "Classe" is a typo of extra "e" or another language version of "class"