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">>
		<<script>>
			Dialog.setup("Character Notes", "characternotes");
			Dialog.wiki(Story.get("Character Notes").processText());
			Dialog.open();
		<</script>>
	<</button>><br>

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">>
		<<script>>
			Dialog.setup("Brianna Benson");
			Dialog.wiki(Story.get("brianna notes").processText());
			Dialog.open();
		<</script>>
	<</button>>
</div>
<img src="images/avatars/brianna.jpg" alt="brianna avatar"><br>
<<else>>
<</if>>

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())
  Dialog.open()
}

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

Example:

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

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