Dialog API Question

If you are requesting technical assistance with Twine, please specify:
Twine Version: 2.3.9
Story Format: Sugarcube 2.31.1

I have a button on the story caption that opens a dialog passage “Character Notes”

<<button "Character Notes">>
			Dialog.setup("Character Notes", "characternotes");
			Dialog.wiki(Story.get("Character Notes").processText());

Then “Character Notes” passage has an avatar picture and a button for each character. The button opens a second dialog for their individual notes passage ie. “brianna notes”

<<if $brianna.met is true>>
<div class="center"><<button "Brianna Benson">>
			Dialog.setup("Brianna Benson");
			Dialog.wiki(Story.get("brianna notes").processText());
<img src="images/avatars/brianna.jpg" alt="brianna avatar"><br>

Is there a way to keep “Character Notes” open when the player closes “brianna notes” Right now it just closes both and the player has to hit the Character Notes button in story caption.

I’m kinda new to this so any help would be appreciated!

All SugarCube dialogs use the same HTML element, thus you can’t show two different ones at the same time that way.

You’d need to either make your own dialog windows or you’d need to close one, open the other, and then re-open the first one when they finish.

Hope that helps! :slight_smile:

You can create a function that opens the “Character Notes” window and tell SugarCube to call it when the “character name” window closes.

In Story JavaScript:

setup.openCharacterNotes = function () {
  Dialog.setup("Character Notes", "characternotes")
  Dialog.wiki(Story.get("Character Notes").processText())

then inside every “character name” button just replace Dialog.open() with Dialog.open(null, setup.openCharacterNotes)


<<button "Brianna Benson">>
    Dialog.setup("Brianna Benson");
    Dialog.wiki(Story.get("brianna notes").processText());
    Dialog.open(null, setup.openCharacterNotes);

This looks like exactly what I was trying to do. I will give this a shot. Thanks for your help!

tested and it works like a charm! Thanks so much!

1 Like