I'm unsure what you're finding confusing about the UI.alert() documentation. It's really not that complicated. As the included example shows, you would normally call it simply with the message you wish to display to the player. As a silly example:
That said. UI.alert() is meant for small text messages, similar to the browser's alert() function. If you want to display markup and images, then you want the Dialog API, which allows you to create your own modal windows containing whatever you want. A common usage is to display a passage within a modal—see: Dialog.setup() for examples.
Here's a simple example of how to open a modal titled "Character Sheet", with the class "charsheet", containing the passage named "PC Sheet":
Thanks that was exactly what I wanted. At first I just ran the <script> and nothing happened so I assumed I wasn't meant to use the <script> function, when really I was just meant to put it inside a <<button>> or <<link>>.
Thanks that was exactly what I wanted. At first I just ran the <script> and nothing happened so I assumed I wasn't meant to use the <script> function, when really I was just meant to put it inside a <<button>> or <<link>>.
No. I simply used <<button>> in my examples. You don't need to use it at all.
If your post is anything to go by, then you simply used the wrong markup: <<script>> vs. <script>. The former is the script macro, which is what you should be using—and you'll note it's what I use in the examples. The latter is the HTML script tag, which is non-functional within SugarCube's markup.
If your post is anything to go by, then you simply used the wrong markup: <<script>> vs. <script>. The former is the script macro, which is what you should be using—and you'll note it's what I use in the examples. The latter is the HTML script tag, which is non-functional within SugarCube's markup.
I tried it exactly as before and it still won't work without the <<button>>. I'm like 95% sure the code is correct so I'm not sure why.
Edit - Just tried it in Chrome and it worked fine, it isn't working in Firefox for some reason.
Comments
I'm unsure what you're finding confusing about the UI.alert() documentation. It's really not that complicated. As the included example shows, you would normally call it simply with the message you wish to display to the player. As a silly example:
That said. UI.alert() is meant for small text messages, similar to the browser's alert() function. If you want to display markup and images, then you want the Dialog API, which allows you to create your own modal windows containing whatever you want. A common usage is to display a passage within a modal—see: Dialog.setup() for examples.
Here's a simple example of how to open a modal titled "Character Sheet", with the class "charsheet", containing the passage named "PC Sheet":
Thanks that was exactly what I wanted. At first I just ran the <script> and nothing happened so I assumed I wasn't meant to use the <script> function, when really I was just meant to put it inside a <<button>> or <<link>>.
If your post is anything to go by, then you simply used the wrong markup: <<script>> vs. <script>. The former is the script macro, which is what you should be using—and you'll note it's what I use in the examples. The latter is the HTML script tag, which is non-functional within SugarCube's markup.
I tried it exactly as before and it still won't work without the <<button>>. I'm like 95% sure the code is correct so I'm not sure why.
Edit - Just tried it in Chrome and it worked fine, it isn't working in Firefox for some reason.
Edit - Reinstalled Firefox and now it works fine.