-
February 27th, 2017, 02:09 #1
onUpdate recursive node event issue
So, I'm trying to add "skills". I have the following fields, base/class_adj/stat_adj/armor_adj/total AND a cycle select. Total has the onUpdate that will collect all those values and set itself to them.
The cycle select will let the player choose from nothing/percentile/str/dex/con/int/wis/char. When it cycles I am trying to set the base based on what they select (if they select str I set the base to the str score/etc). When I set the base value I get the alert of a recursive node event. The change to the base is causing the onUpdate bit for total to run again.
This is the bit that sets it.
Code:nValue = DB.getValue(nodeChar, "abilities." .. sAbility .. ".score", 0); DB.setValue(nodeSkill, "base_check","number", nValue);
Any suggestions?
edit...update
As a work around for now I've just made the base_check field hidden if they select the ability score types and just fill that in behind using ability score.Last edited by celestian; February 27th, 2017 at 05:40.
-
February 27th, 2017, 22:57 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,566
You get the recursive event warning when you create an endless cycle within your code. (Ex: you write an onValueChanged handler that calls setValue on itself)
In this case, something in your onUpdate handler code is triggering an action that changes the database value that triggered the original onUpdate event.
To remove the warning, you need to rework your logic or data structure so that the onUpdate code doesn't modify the original database node that triggers the event.
Regards,
JPG
-
February 27th, 2017, 23:04 #3
Yup, sorry I thought I explained that bit. I was setting a field that caused an update within the onUpdate.
That's the tricky part I couldn't figure out. Well, I did but I'm not sure it's best. I just removed base_check update and "hide" the box when it's not percentile (it's str/dex/etc) and then just retrieve current dex/str/whatever during the check/total calc from mods.
I couldn't think around it to come up with an option that let me set the value to a default with ability score option selected.
-
February 28th, 2017, 02:22 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,566
It's impossible to tell without seeing all the XML/Lua for the class, as well as the controls. It's possible you already have a reasonable solution, so just go with it if it works.
Cheers,
JPG
-
March 8th, 2017, 06:01 #5
Figured I'd post a working "solution" incase anyone else runs into this problem.
So, while futzing with something else I ran into a problem I needed to set something with an onUpdate set. This was just for testing so I wanted to make it work... and I thought of trying this which seems to work.
Code:DB.removeHandler(nodeWeapon.getNodeName(), "onChildUpdate", onDataChanged); DB.setValue(v, "damageasstring","string",sDamage); DB.addHandler(nodeWeapon.getNodeName(), "onChildUpdate", onDataChanged);
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks