Text box/buttons in SugarCube dialog

Twine 2.5.1
SugarCube 2.36.1

I’ve done a lot of searching and I can’t find any examples that allow for use of a text box or buttons within a Sugar Cube dialog. I’ve tried adding the script within the Dialog.append(), Dialog.body(), and Dialog.wiki(), but all of these just crash. Any help would be greatly appreciated.

1 Like

Welcome, Wrig9.

You’re close with Dialog.wiki(). You need a little something between the parentheses.

For instance, here’s what it would look:

<<button "Pies">>
<<script>>Dialog.setup("Preferred pie");
Dialog.wiki(Story.get("Flavor").processText());
Dialog.open();
<</script>>
<</button>>

You can have it to almost dynamically update the page… For instance:

<<if def $pie>>$pie<<else>><<button "You've not defined you're preferred flavor yet!">><<set _passage to passage()>>
<<script>>Dialog.setup("Preferred pie");
Dialog.wiki(Story.get("Flavor").processText());
Dialog.open();
<</script>>
<</button>><</if>>

And in the “Flavor” passage:

<<textbox "$pie" "Blueberry">>

<<button "Go back" _passage>><<script>>Dialog.close()<</script>><</button>>

Thanks, it worked great and makes plenty of sense, but for anyone having this problem in future I had to use <<link>> instead of <<button>> in StoryMenu. No big deal, and it was still a big help.