PDA

View Full Version : Load order of extensions



Kelrugem
October 6th, 2019, 01:46
Hi :)

I might have a question which is probably already asked before but I only found very old threads about that subject such that I do not know how actual the answers are :)

My problem is that some of my extensions for 3.5e/PF1 are incompatible with other ones, I normally then provided combined extensions to make them compatible but, although it is often straightforward to merge the code, it is tedious and when one is not careful then one copies some part of the code to the wrong file etc. :) Especially when there is a new bigger update for FG or when I make updates on my own extensions then I have to redo this merging more or less and I try to reduce this work. On one hand I could simply just make one big extension but not everyone does want to use all provided extensions and so I still want to provide the possibility to choose which extensions are loaded. Adding options in the option menu might clutter the options, so I am not sure if that would be suitable

I've seen in the enhanced images extension of Trenloe and Zeus that there is some loadorder tag. Is it "easy" to use or should one be careful when using it (when searching the forums I just found a lot of warnings about playing with the load order of extensions, but it were old threads and it was not really clear to me what the procedure is and where the problems are)? :) And is there information about how this tag is used? I would like to use it in such a way that my extensions are loaded at the end such that my changes are not overwritten and my code is then adjusted by if-clauses which measure if some other extension is loaded (and I hope that this is possible somehow); when the other extension is loaded then the code looks like the merged code, otherwise just the standard code with my adjustments. In that way I hope to avoid package-extensions in the future :)

Thanks in advance :)

Best,

Kelrugem

Moon Wizard
October 6th, 2019, 03:34
The loadorder tag simply specifies the order in which the extensions are loaded. Extensions with a lower number are always loaded before a higher number. If they have the same number (such as the default of zero), then there is no guaranteed load order.

It's a pretty simple feature, and there is no "standard" of what load order tags should be used. It's basically a mechanism to allow extension creators to work with others to fine tune load order.

Regards,
JPG

dulux-oz
October 6th, 2019, 03:44
And for the record, all of the DOEs have a LoadOrder of 50 (as per the DOE documentation) - except for the DOE:Base, which *must* be loaded first, and it has a LoadOrder of 40.

Kelrugem
October 6th, 2019, 03:47
Aaah, okay, thank you very much both for your answers, that sounds indeed simple :) I thought as such but I rather wanted to ask first, not that I miss something crucial :)

Thanks a lot, then I play with that a bit :)

LordEntrails
October 6th, 2019, 23:32
It seems to me that even a very rough recommended list would be helpful. Maybe something like;
Ruleset modifications 10-39
Enhanced functionality 40-79
Themes 80-99

Would that make sense in a majority (Not all!) cases?

dulux-oz
October 7th, 2019, 03:04
It seems to me that even a very rough recommended list would be helpful. Maybe something like;
Ruleset modifications 10-39
Enhanced functionality 40-79
Themes 80-99

Would that make sense in a majority (Not all!) cases?

Well, there's no need to stick to a 2-digit number. In the past I've recomended Devs who work with me to put Themes above 100. But yeah, something like that might work - but only if every Dev sticks to the eventual agreed ranges. :)

Kelrugem
October 7th, 2019, 05:15
Okay, I got that working with picking loadorder of 39 (for a loadorder of 5 I couldn't assure that my extension is loaded after some other extension for some reason; am I right that extensions without any loadorder are loaded first (in random order but before extensions with defined loadorder) or do they get a random loadorder in the range/interval of the number of loaded extensions?).

I then wanted to use this function here https://www.fantasygrounds.com/refdoc/Extension.xcp#getExtensions, but

Extension.getExtensions();
just results into an error

Script Error: [string "scripts/manager_action_attack.lua"]:24: attempt to index global 'Extension' (a nil value)

Am I using this function somehow wrong? :) When I understood it correctly then one has to add the name (here "Extension") of the package in front of the function name, so I wonder what my mistake here is :)

Trenloe
October 7th, 2019, 14:25
It seems to me that even a very rough recommended list would be helpful. Maybe something like;
Ruleset modifications 10-39
Enhanced functionality 40-79
Themes 80-99

Would that make sense in a majority (Not all!) cases?
The loadorder is really not based on the functionality, it's based on what gets modified, what other extensions that extension needs to override (if any) and what the likelihood of other extensions modifying that code will be. The extension that loads last overwrites earlier loaded extensions.

LordEntrails
October 7th, 2019, 17:59
The loadorder is really not based on the functionality, it's based on what gets modified, what other extensions that extension needs to override (if any) and what the likelihood of other extensions modifying that code will be. The extension that loads last overwrites earlier loaded extensions.
What would be a better recommendation? Obviously there will be many exceptions, but a starting point seems beneficial.

Trenloe
October 7th, 2019, 18:02
What would be a better recommendation? Obviously there will be many exceptions, but a starting point seems beneficial.
Keep the load order low, so that other extensions could override it easily if need be, unless you need to override another extension - in which case, make your load order a little higher than the extension you're overriding (maybe 10 higher).

Kelrugem
October 7th, 2019, 18:56
Okay, I got that working with picking loadorder of 39 (for a loadorder of 5 I couldn't assure that my extension is loaded after some other extension for some reason; am I right that extensions without any loadorder are loaded first (in random order but before extensions with defined loadorder) or do they get a random loadorder in the range/interval of the number of loaded extensions?).

I then wanted to use this function here https://www.fantasygrounds.com/refdoc/Extension.xcp#getExtensions, but

Extension.getExtensions();
just results into an error

Script Error: [string "scripts/manager_action_attack.lua"]:24: attempt to index global 'Extension' (a nil value)

Am I using this function somehow wrong? :) When I understood it correctly then one has to add the name (here "Extension") of the package in front of the function name, so I wonder what my mistake here is :)

I solved my issue :)

The trick was that the other extension (here the mirror image handler of darrenan for PF1) has a unique lua script with its own name, "MirrorImageHandler". Then with

if MirrorImageHandler then
[merged code]
end
I was able to make my extension compatible with this extension (my loadorder is now put to 20, so I decreased it a bit again after your discussion here, Trenloe and LordEntrails, thanks :) ).

Oh man, would I have known this some months ago this could have simplified my coding a bit when it is about compatibility issues :D I may change this now with my existing packages but I am not sure since the users of my extensions are now used to the previous way and I am not sure how to communicate the change such that everyone knows about that :)

Thanks again all :)