Anyone know a method to close the Dialog box without clicking? While in the dialog box, I want to send the player to another passage, but the Dialog box still appears on the new passage. I tried running <<run Dialog.close()>>
right before and after using the <<goto>>
macro, but it doesn’t close it.
That certainly should work. Is there any chance that some code is then reopening the dialog on the new passage, rather than the close itself not working?
For instance, I would like to close the Dialog box automatically after going to the passage “Death scene”. This method does not close it.
<<link "Go north">>
<<run Dialog.setup("Time is running out")>>
<<run Dialog.wiki("<<if $timer < 10>>You check your wristwatch and realize time is running out. You need to find the escape route before the chamber is filled with gas.<<else>><<run Dialog.close()>><<goto 'Death scene'>><</if>>")>>
<<run Dialog.open()>>
<</link>>
From the code you gave, the popup will “generate” and the code renders before the popup actually opens. Assuming you don’t want a popup when $timer =>10
, I’d suggest doing this instead:
<<link "Go north">>
<<if $timer < 10>>
<<run Dialog.setup("Time is running out")>>
<<run Dialog.wiki("You check your wristwatch and realize time is running out. You need to find the escape route before the chamber is filled with gas.")>>
<<run Dialog.open()>>
<<else>>
<<goto 'Death scene'>>
<</if>>
<</link>>
EDIT: follow up question, is the <<link>>
code already in a popup? or just in a regular passage?
From a passage, but at points I would like to navigate from already inside a dialog pop up as well.
Your issue then is that you are running the <<run Dialog.close()>>
too soon.
The normal way to handle this is to put your close()
behind some sort of user interaction, such as inside a <<link>>
. e.g.
<<link "Onwards" "Next Passage">>
<<run Dialog.close()>>
<</link>>
If you want it to be automatic, you can use <<timed>>
to do it instead, so that it will happen some fixed number of seconds after the Dialog opens. e.g.
<<timed 10s>><<run Dialog.close()>><</timed>>
Alright playing around with this, if I move the Dialog.open()
before the Dialog.wiki()
, it closes it without having to use the <<timed>>
In alI the online usage of this, the Dialog.open()
was always put below the wiki, so wonder if there is any downside to doing it like this. It does seem to accomplish what I want though!
My guess would be that the Dialog.close()
does nothing at that point, because it is executed when the dialog is already closed, and then you open it afterwards.
Are you seeing it open, and then close itself?
Run the code from my second post, first with the Dialog.open()
placed last, and then with it preceding Dialog.wiki()
. In the first instance, the dialog box is still open after going to the new passage, in the second instance, it’s closed which is what I was wanting.
Right, but that means the Dialog is never shown, in which case you should do as @manonamora suggested, and never open it in the first place, because whatever is in your Dialog still gets run, and could have side-effects.
I thought you wanted it to open, and then close itself, my bad