Joshua Stream Pre
  1. #1
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    22,514
    Blog Entries
    1

    Help with merging templates

    Hi team,

    I have an extension that needs to modify the CoreRPG chatwindow_step template.
    My requirement is to add new modeframes

    I have added 7 lines like below to the existing 3
    Code:
    <modeframe mode="group" name="chatframe_group" offset="40,10,10,40" />
    I have not been successful in doing any combinations of merge in regards to this and so included the whole template in my extension with the changes.

    The issue is this breaks compatibility with other extensions that modify this template - namely the ondemand manual dice and the 2E ruleset

    What is breaking there is that script replaces the script in this line
    Code:
    <script file="desktop/scripts/chat_window.lua">
    Any suggestions on how I can merge in just the new modeframes?

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  2. #2
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    3,012
    I've also been tinkering with options to try and get around this. Currently the template I use for the chatwindow_step is....

    Code:
    	<template name="chatwindow_step">
    		<chatwindow name="chat"  merge="join">
          <linkicon normal="button_link" pressed="button_link_down" mergerule="replace" />
    			<script file="desktop/scripts/chat_window_adnd.lua" mergerule="replace"/>
    		</chatwindow>
    	</template>
    To be honest I'm not sure if merge/replace works in templates (not run extensive testing). That said the above does WORK. The script that runs from this does some replacement for onDrop to capture the dice drop and look for "control" being pressed and if so do something.

    If there is something I can do to make these coexist I'll happily do it. I've tried various things but I've had no luck but I've not had time to do extensive testing.
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  3. #3
    The merge/mergerule attributes work within template definitions to define how templates are merged together when they are layered. The template definitions themselves (i.e. template name="...") do not support merge attributes.

    When I need to do this, I just copy the original template, and make the changes to the copy in the new layer. You can get more complex, but that's the easiest.

    Regards,
    JPG

  4. #4
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    22,514
    Blog Entries
    1
    Hi Moon Wizard,

    That is what I have done. So the challenge is to make it co-exist with another extension that changes only the script file.
    Can you think of a way to change which script the template will use based on something like this?

    Code:
                    for k,v in pairs(Extension.getExtensions()) do
                        if string.find(v,"onDemandManualDice") then
                            **use ondemand extension script**
                            return true;
                           else **use corerpg script**
                        end
                    end
    Or some other way?

    Otherwise ill do two versions.

    MoreCore - Generic Ruleset
    --- Projects ---
    Extensions | Tutorials | MoreCore | MoreCore Themes | Call of Cthulhu | Maelstrom | FG Con

  5. #5
    Yeah, working with another extension is challenging. I do have some near term stuff planned for extensions working with multiple rulesets, but nothing like what you need right now.

    Usually, I check for existence of a global script to determine whether an extension is loaded, but the getExtensions() method works too. Usually, both extensions need to be written to work well with the other, so they can work together without stomping on each other. Needing custom templates makes that a little harder.

    Two versions is probably simplest for short term.

    Regards,
    JPG

  6. #6
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    3,012
    Quote Originally Posted by Moon Wizard View Post
    Yeah, working with another extension is challenging. I do have some near term stuff planned for extensions working with multiple rulesets, but nothing like what you need right now.

    Usually, I check for existence of a global script to determine whether an extension is loaded, but the getExtensions() method works too. Usually, both extensions need to be written to work well with the other, so they can work together without stomping on each other. Needing custom templates makes that a little harder.

    Two versions is probably simplest for short term.

    Regards,
    JPG
    If the merge bits work shouldn't he be able to insert the bit he needs and they both will "include" the parts both added? Far as I know he's not changing the script that I am, just adding some modeframes.

    Code:
        <template name="chatwindow_step">
          <chatwindow name="chat"  merge="join">
           <modeframe mode="world" name="chatframe_world" offset="40,10,10,40" />
           <modeframe mode="place" name="chatframe_place" offset="40,10,10,40" />
           <modeframe mode="group" name="chatframe_group" offset="40,10,10,40" />
           <modeframe mode="religion" name="chatframe_religion" offset="40,10,10,40" />
           <modeframe mode="clue" name="chatframe_clue" offset="40,10,10,40" />
         </chatwindow>
        </template>
    But, he said that didn't work.
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  7. #7
    You can't merge two templates. They're purely layered. The merge/mergerule attributes just affect how each tag merges when they're layered.

    Regards,
    JPG

  8. #8
    celestian's Avatar
    Join Date
    Jan 2017
    Location
    DFW, Texas
    Posts
    3,012
    Quote Originally Posted by Moon Wizard View Post
    You can't merge two templates. They're purely layered. The merge/mergerule attributes just affect how each tag merges when they're layered.

    Regards,
    JPG
    Ah, ok misunderstood then.

    Bugger, this is going to be a pain
    ---
    Fantasy Grounds AD&D Content Bundle (All The AD&D Content)
    Coding the Official AD&D Ruleset
    Documentation for AD&D 2E ruleset.
    My Twitch Channel for AD&D and FG related streams (See schedule for live days)
    My YouTube for FG related Tutorials and AD&D Actual Plays
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)

  9. #9
    For the modeframe issue, I recently ran into this myself - the solution seems to be to make the changes where the templates are used.

    ie, I was trying in template_desktop.xml
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?>
    
    <root merge="join">
        <template name="chatwindow_step" merge="join">
            <chatwindow name="chat" merge="join">
                <modeframe mode="lillabilities" name="chatframe_lillability" offset="5,5,5,5"/>
            </chatwindow>
        </template>
    </root>
    and ran into the issue where this would knock out all existing modeframes. What worked instead was going in desktop_classes.xml and doing
    Code:
    <root>
    	<windowclass name="chat" merge="join">
    		<sheetdata merge = "join">
    			<chatwindow name="chat" merge="join">
    				<modeframe mode="lillabilities" name="chatframe_lillability" offset="5,5,5,5" mergerule="add"/>
    			</chatwindow>
    		</sheetdata>
    	</windowclass>
    	<windowclass name="chatlocal" merge="join">
    		<sheetdata merge = "join">
    			<chatwindow name="chat" merge="join">
    				<modeframe mode="lillabilities" name="chatframe_lillability" offset="5,5,5,5" mergerule="add"/>
    			</chatwindow>
    		</sheetdata>
    	</windowclass>
    </root>
    with the caveat that I also had to go change the code of the other extension that added its own modeframe and do the same there for them to co-exist.

Thread Information

Users Browsing this Thread

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Product Walkthrough Playlist

Log in

Log in