Thread: Help with merging templates
-
March 14th, 2020, 03:47 #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" />
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">
-
March 14th, 2020, 04:04 #2
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>
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 Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
March 14th, 2020, 05:31 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,626
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
-
March 14th, 2020, 06:04 #4
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
Otherwise ill do two versions.
-
March 14th, 2020, 06:29 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,626
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
-
March 14th, 2020, 06:43 #6
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>
---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
March 14th, 2020, 07:39 #7
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,626
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
-
March 14th, 2020, 07:54 #8---
Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
Documentation for AD&D 2E ruleset.
Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.
-
October 25th, 2020, 00:24 #9
- Join Date
- May 2020
- Posts
- 24
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>
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>
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks