-
October 3rd, 2017, 18:29 #11
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,570
Things to Know
General
* You are trying to "merge" in your scripts. Scripts don't allow merging, but they do layer. It's very similar, but an important distinction. This happens automatically and no merge tag is required.
* For layers, script calls will fall through to a lower layer, but any calls on the same layer only call functions on the same layer. This can be bypassed by using "super" and "self" variables.
* Additionally, each layer has it's own scope, which means that local variables are only accessible within the layer, not across layers.
getWindowSortByNode
* So, the reason your getWindowSortByNode is not getting called is because, the call to getWindowSortByNode in the original script is the one in the same layer as the updateHeaders function. (i.e. not yours which is one layer higher)
setHeaderCategory
* Since the setHeaderCategory calls are being made from outside the script, then the calls start at the top layer and fall down through the layers. Since your newly defined script is the top layer, then your version of setHeaderCategory is getting called.
The Fix
Since you are trying to replace a function that is only called within the same script and uses variables that are local to the script that other functions also depend on, you will need to replace the entire script in that case. So, you would need something like:
Code:<windowclass name="power_page" merge="join"> <script merge="delete" /> <script file="campaign/scripts/power_page_new.lua" /> </windowclass> <windowclass name="power_group_header" merge="join"> <script> function setHeaderCategory(rGroup, sGroup, nLevel, bAllowDelete) if sGroup == "" then name.setValue(Interface.getString("char_label_powers")); name.setIcon("char_abilities_orange"); else if rGroup.grouptype ~= "" then if not nLevel then name.setValue(sGroup); elseif nLevel == 0 then name.setValue(sGroup .. " (" .. Interface.getString("power_label_groupcantrips") .. ")"); else name.setValue(sGroup .. " (" .. Interface.getString("level") .. " " .. nLevel .. ")"); end name.setIcon("char_powers"); level.setValue(nLevel); else name.setValue(sGroup); name.setIcon("char_abilities_orange"); end group.setValue(sGroup); setNode(rGroup.node); if bAllowDelete then idelete.setVisibility(true); end end end </script> </windowclass>
JPG
-
October 3rd, 2017, 18:32 #12
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,570
BTW, thanks for the work to narrow down the issue to a very specific scenario. It allowed me to understand what you were trying to do quickly, and be able to provide feedback.
Regards,
JPG
-
October 4th, 2017, 15:33 #13
You're more than welcome. It seems only prudent to me, that when asking for help, I should try to facilitate it as much as possible.
Now on to the "layering" of script. Ug, additional complexity to contend with. I believe I can see how the layering of code would provide a great deal of flexibility, but in my limited experience in FG extension design, it appears fraught with uncertainty. I need to be mindful.
Thank you for your time and explanation.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks