PDA

View Full Version : Modify "local" function (Example: skillist 5e ruleset)



Simerion
June 8th, 2020, 17:17
I added another field to the skilllist of a 5e character. This field is to be prefilled with when initializing the available skills. The background is a "soft" translation, which does not affect the program code of 5e, and simply shows a translated name in addition to the original english name (I will do the same for some other places: Both the English text and the German text should appear, but FGU should be able to use the English texts for logic purposes).

Now the initialization is not "globally" reachable (as far as I understand it so far). It is included in the character in the skilllist. I would hate to have to copy the window as a whole to add the functions (also to have as few dependencies on rule changes as possible).


...
<windowlist name="skills">
...
<datasource>.skilllist</datasource>
<class>skill_item</class>
<sortby, control, name, control, sortby.
<script file="campaign/scripts/char_skilllist.lua" />
</windowlist>
...


The affected function ("constructDefaultSkills") is taken from the file "campaign/scripts/char_skilllist.lua" (5th set of rules) and will be included in "record_char_skills.xml" on the skilllist-level. How can I overwrite (add functionality) to this function without changing too much of the character sheet?

superteddy57
June 8th, 2020, 18:23
If your extension has the windowclass already modified and the windowlist is in that windowclass, then you copy the lua file and place it in the same location it is searching for it in your extension. Then you can modify that lua file with your changes.

Simerion
June 9th, 2020, 07:49
If your extension has the windowclass already modified and the windowlist is in that windowclass, then you copy the lua file and place it in the same location it is searching for it in your extension. Then you can modify that lua file with your changes.

I did not change the window class with the list, only added the window class in which a single list entry was defined. I would like to adapt as little as possible to the existing character sheet. Is it possible to change only the definition of the windowlist in the parent window?

superteddy57
June 9th, 2020, 14:05
Since the lua file is not a global script, you would have to include the windowlist with your extension to point to your modified lua file. If it's not included, it will point towards the original file without the modifications you have made to it. That is why I am recommending to include the windowclass and windowlist in your code. The easiest would be to copy the file you wish to modify to your extension and then make modifications to copied file. This would ensure that your modified lua file will be accessed when you run your extension.

Trenloe
June 9th, 2020, 14:14
What @superteddy57 suggests is the quick and strait forward approach. Keep in mind that copying big sections of code from the ruleset to an extension means that you’re more likely to have to keep updating your extension when there’s updates to the ruleset in future - as you’ll need to make sure that the code you copied from the ruleset gets updated in line with ruleset changes to that code.

Also, the more code you copy over, the more chance you have of your extension clashing with another extension.

I’m not saying don’t do it, its what I did for a few years, I just want to be clear about the implications. Even minimizing code use through merging controls and scripts doesn’t completely eliminate the possibilities of upgrades and other extensions causing issues, it just reduces the chance.