PDA

View Full Version : Merge classes - campaign_chars and list_iadd



Xarxus
August 27th, 2023, 16:49
I'd like to modify charselect_host and charselect_client (campaign_chars.xml)
to force list_iadd to do something I want. So I've prepared a campaign_chars.xml version and used merge="join".
<windowclass name="charselect_host" merge="join">
<sheetdata>
<button_iadd name="list_iadd">
<anchored to="rightanchor">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<class>charsheet</class>
<script>
function onInit()
Debug.console("onInit")
end
function onButtonPress()
Debug.console("onButtonPress", window.getDatabaseNode());
end
</script>
</button_iadd>

</sheetdata>
</windowclass>

<windowclass name="charselect_client" merge="join">
<sheetdata>
<button_iadd name="list_iadd">
<anchored to="rightanchor">
<top />
<right anchor="left" relation="relative" offset="-5" />
</anchored>
<class>charsheet</class>
<script>
function onInit()
Debug.console("onInit")
end
function onButtonPress()
Debug.console("onButtonPress", window.getDatabaseNode());
end
</script>
</button_iadd>

</sheetdata>
</windowclass>
When i test this code I've the right messages in console, but it alsto creates a new
entry inside the charsheet tag. I guess is done by the old code
...
local node = DB.createChild(window.getDatabaseNode());
...

Surely merge="join" isn't right, so tried a combination of replace, merge and whatsover,
even on
<button_iadd name="list_iadd"> without any success.

How can I do it?

Xarxus
August 27th, 2023, 21:13
I think I found why it creates a new charsheet.
In the function onButtonPress I was operning my charwizard with this code.
Interface.openWindow("charwizard", window.getDatabaseNode());
On guides I found this

Creates a top level window by a windowclass and a datasource. If a matching window already exists, it is returned. Otherwise, a new window is created.

Moon Wizard
August 27th, 2023, 21:26
Character wizards should be sourceless (i.e. "" for data path in Interface.openWindow), in order to avoid creating data until the character has been committed. That's how all of our character wizards work.

On a related note, the template used for "list_iadd" is changing in the upcoming release this week. You'll need to update your scripts.

Another option for character wizard is to add a top-level button (like 5E) or to add a new button (next to iadd) that opens wizard instead of blank character.

Regards,
JPG