Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Popup Macro, SugarCube 2

Somewhere between @Claretta and @TheMadExile, there is a great popup macro for use in SugarCube. When I use it though, the window stays up and let's the user keep clicking on the list of choices while the screen in the back changes (therefore ruining any hope of surprise or accountability).

Does anyone know how to make this close itself automatically after the person clicks (as the person clicks) so that they can only choose one?

Thank you in advance.

Comments

  • What construct are you using for the choices?
  • Literally just this
    Do you:
    [[Kick the door open|KickDoor]]
    [[Slowly open the door|OpenDoor]]
    [[Inspect the door|InspectDoor]]
    
  • edited June 2015
    Either of the following should work.

    Via macro:
    /* Creates a link that closes the dialog (and maybe does other things) */
    <<click [[Kick the door open|KickDoor]]>><<script>>UI.close()<</script>><</click>>
    
    Via HTML:
    /* Creates a link that closes the dialog */
    <a class="link-internal ui-close" data-passage="KickDoor">Kick the door open</a>
    
    The first closes the dialog by calling UI.close() directly, while the second closes the dialog by having the class ui-close attached to it.

    You could automate either of those with a widget to make them a bit shorter to type. For example:
    /* Setting up a widget that uses <<click>> (goes in a widget tagged passage) */
    <<widget "dialogclose">><<click $args[0]>><<script>>UI.close()<</script>><</click>><</widget>>
    
    /* Usage */
    <<dialogclose [[Kick the door open|KickDoor]]>>
    
  • Solid work, TME. Thank you again for all your help.
  • .
    On another note, I decided on the automation route. For the record I didn't even know that way was a thing that one could do.

    Thank you again.
Sign In or Register to comment.