5E Character Create Playlist
Page 1 of 4 123 ... Last
  1. #1

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247

    Query Regarding How Extensions Load

    Greetings,

    I have the following situation - and I would like to see if anyone can explain why it is happening ...

    Two extensions (loadorders 105 and 110).

    Both have a common code base (included vial <includefile>) which contains strings, scripts and templates.

    When I load a single extension, everything works as expected ... no problems ... everything is working ... YAY.

    However when I load both extensions, the common code base is not loaded for 105 (and hence it fails to setup/execute) however it does load for 110.

    From my own experimentation (using Debugs), if the same <script> is encountered during load, it is ignored (or seems to be ignored) which is perfectly fine.

    However 105 should be loading these in first, then 110.

    Can anyone enlighten me please? The only other options I have are 1) Create a common extension that must be loaded first or 2) duplicate all my code with different tags etc (not ideal at all).

    As an aside, if I include the same string file - it should override the previous one correct?
    Thanks In Advance,
    D

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    The thing to remember is that the code is not executed as the extensions are loaded, the code is being instantiated in FG's memory and that code will be executed once the ruleset and all extensions have been loaded.

    Additionally, how scripts are instantiated depends on where they're defined.

    If they are in extension.xml then yes, the last <script> file to be instantiated and will be the script that is used when the FG instance executes the loaded code as these are global script files and the <script> command on its own will override previously configured global script packages of the same name.

    If the <script> is within a windowclass or control, then the scripts will be layered - in the order of them being defined. You can access the code in an earlier windowclass/control <script> definition by using the super variable. See script block scope in the Wiki here: https://fantasygroundsunity.atlassia...pt-Block-Scope
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    So from what you are saying is the following :

    Extension 105 loads ... it loads the common code via <includefile source="100/100.xml" />

    In this case it is the very first line in <base> for extension 105.

    Extension 110 loads ... it loads the common code via <includefile source="100/100.xml" />

    And once again it is the very first line in <base> for extension 110.

    in 100.xml there is a series of includefiles (for strings) and scripts (for common libraries and utilities - for example a serialisation library, extensions to common LUA types and so on).

    They get loaded and execution of those extensions begins ... now since 110 essentially overrides 105 in the case of this common library, the code execution of the common library will not occur until 110 executes ... have I got that correct?

    If that is so then the only solution is a common extension that MUST be loaded first to get all the common code loaded first (which makes the extensions a little kludgey), or I have to include all of the common code in each extension, ensuring the scripts that are loaded use unique names (even though the code is identical).
    Last edited by UrsaTeddy; October 3rd, 2022 at 04:40.
    Thanks In Advance,
    D

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,411
    Quote Originally Posted by UrsaTeddy View Post
    They get loaded and execution of those extensions begins ... now since 110 essentially overrides 105 in the case of this common library, the code execution of the common library will not occur until 110 executes ... have I got that correct?
    As mentioned previously, code doesn't get executed until all of the rulesets (usually CoreRPG plus a layered ruleset) and extensions are loaded into memory - with the code overwriting/layering based on the order and type of the code.

    So, something like this:
    1. CoreRPG code is loaded into FG's memory, no code is executed.
    2. The layered ruleset code is loaded into FG's memory, no code is executed. Let's assume this is the 5E ruleset for example purposes.
    3. The first extension code is loaded into FG's memory, no code is executed.
    4. The code of subsequent extensions is loaded into FG's memory, no code is executed.

    The LUA code and XML definitions can be modified by subsequent steps in the above list. XML could merge or overwrite depending on the layering tags used - some info here: https://fantasygroundsunity.atlassia...set+-+Layering LUA code will either overwrite global script packages or layer the code (if embedded in windowclasses or controls).

    Quote Originally Posted by UrsaTeddy View Post
    If that is so then the only solution is a common extension that MUST be loaded first to get all the common code loaded first (which makes the extensions a little kludgey), or I have to include all of the common code in each extension, ensuring the scripts that are loaded use unique names (even though the code is identical).
    This is all theoretical and I can't give firm recommendations without knowing the code. There are ways of overriding individual functions in a global script package and scripts in windowclasses/controls are layered and so the lower down layer code can be executed via the super variable. But, if I understand you correctly, if you have a set of frequently used functions then you do essentially have two options for use in multiple extensions: 1) Have a library extension that needs to be loaded to use the extensions (which can cause use/support issues) or include that code in every extension - and maintain it in every extension. You wouldn't need to use different global script package names, just ensure the code is compatible in each extension - with the last extension loaded being the extension whose global script package will be used.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  5. #5

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    I must not have been clear with my previous query.

    What I want to know is that if the common code - which is 100% compatible with both extensions individually - is executed with the last extension to load it rather than executing the code (overwritten or otherwise) in the order of extensions.

    Therefore 105 loads with common code loading
    110 then loads, overwriting all the common code with the common code (since it is including the exact same code)

    After loading, execution begins in the order of extension load order (assumed).

    Since extension 105 has had its "common code" overwritten by 110 I am understanding that the "common code" is not executed until 110 is executed.
    Thanks In Advance,
    D

  6. #6

  7. #7

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    @damned ... actually in my case it is executed

    my common code goes something like this ....

    common type 1
    common type 2
    common type 3
    common manager 1

    extension 105 loads the common code and sets up options and some other things that are 105 exclusive. On its own it works perfectly.
    extension 110 loads the common code and sets up options etc. On its own it works perfectly.

    When I attempt to load 105 and 110 in the same campaign (currently development so only those 2 extensions)

    extension 105 fails to load because it cannot find common type 1 etc that it needs
    extension 110 succeeds because it finds everything it needs has been loaded

    so all i have ascertained is that somehow 105 has "lost" its common code because 110 overwrote it and hence cannot execute it.
    Thanks In Advance,
    D

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    I really dont follow

    you say the common code IS executed by extension 105 but doesnt work because its overwritten by 110?
    its either executed or not executed

  9. #9
    Overwritten global script code is not run, nor fully replaced windowclass or template scripts.

    Scripts used in template/control definitions and scripts in merged windowclass definition are merged together in layers.

    Priority order for window classes:
    Last defined merge in reverse order.

    Priority order for templates/controls:
    Window class control definition is top level, then templates are resolved by replacement with scripts stacked in decreasing priority.

    Regards,
    JPG

  10. #10

    Join Date
    Mar 2020
    Location
    Sydney, Australia
    Posts
    247
    @damned

    Okay I have two extensions 105 and 110.

    Both extensions use a common code base.

    Individually (only extension loaded) all is 100% okay, extensions work as intended, including connection detection, OOB, etc.

    When loaded together, both extensions load and then the execution phase begins.

    105 tries to execute code that references the common code and fails ... cannot find commontype1.blah()
    110 tries to execute code that references the common code and succeeds ... it can find commontype1.blah()

    to test if it succeeded I was using Debug.chat("BLAH IS EXECUTING").
    Thanks In Advance,
    D

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in