tmedwards / sugarcube-2

SugarCube is a free (gratis and libre) story format for Twine/Twee.
https://www.motoslave.net/sugarcube/2/
BSD 2-Clause "Simplified" License
185 stars 42 forks source link

Documentation Request: Dialog.open Clarification and Examples #128

Open claws61821 opened 3 years ago

claws61821 commented 3 years ago

The SugarCube v2 Documentation entry for the Dialog API's "open" call Dialog.open is currently ambiguous as to how to define the parameters for the options and closeFn placeholders, particularly for new users who are just picking up Twine and have little or no experience with JavaScript or other programming languages, and the only code example provided is simply Dialog.open(); without comments or variation.

Since some languages and CLIs require calls and definitions on-use for every formal parameter or placeholder that isn't fully predefined, and can require those calls and definitions made in different ways, this ambiguity can cause confusion for users who aren't strictly familiar with whichever one they're using at a given moment. For example the subsection header for the entry in question, Dialog.open([options [, closeFn]]) → Dialog object, led me to think that use of closeFn here wanted either Dialog.open(options(closeFn())); or, if it was a typo, Dialog.open(options(),closeFn()); with potential definitions of (options(null, closeFn(null))); or (options = null, closeFn = [function]); whereas I was later told in the Twine Discord server that it wants the placeholder calls bypassed entirely (ex. Display.open(null, [function]);).

Can you please clarify both here and in a near-future update of the Documentation what is the correct parametric syntax for Dialog.open and provide code examples for new users?

Thank you very much. Your time is appreciated.