Dialog Window Function

Published 2023-06-12

(v02 07-21-22)

TO LOAD THIS PICO-8 CART, in immediate mode, type: load #dialog

VVHAT'S NEW ?

As I continue to work on my main Pico-8 program, I thought I would share with you one of the functions I wrote specifically for notifications.

You've probably seen it yourself, you attempt to close NOTEPAD without saving your work and you get a notice prompting you to save your file first.

Well this is my answer for Pico-8 as it does not have one. Now if @zep does decide to make a function that can do a dialog frame with input, I'd be all for it. Until then you have this.

And it works perfectly for normal text. If you include the @000 with the 3-digits for custom icons to appear in the text, then you should really separate it by spaces, thus: this @000 image.

Included above is a sample program using the standard _init() and _update() functions so it should work for you.

Press 🅾️ to bring up the dialog frame. Select YEP to clear the screen. Select instead NOT YET to skip over clearing the screen. See the source-code to see how this works.

My function uses a few arguments in the calling of it: Message, Title, Query, Icon, and Color set.

MESSAGE is required. You can also use "-" to hyphenate words so they will appear on 2-lines. Use @000 with 3-digits to display that icon # at that position in the message. Message also does not need to have spaces or divisions to match the screen and can be pretty big at that. All of the characters calculated for across and down are automatically determined inside the code so you just type out the sentence or question you want.

.

.

TITLE is just the text that appears at the top. If NIL then the word "NOTICE" will appear instead.

QUERY is a single string comma delimited entry that gives you the choices for this dialog window. If left to NIL then there will only be one choice, "OKAY" to appear. You can have as many choices as will appear. What returns from the function is a single character representing the first letter of the choice the user has selected with the 🅾️ key. ❎ is not being used at this time.

Icon like title and query are optional. If left to NIL it will not be displayed. If so it will appear in the top-right-hand corner of the screen and appears best at 7x7 pixels.

Color set are the four colors you choose to display the dialog window with. From darkest to lightest. If left to NIL the color set is 0, 1, 13, and 7.

When the dialog window appears use the arrow keys to change the choice. "?" is initially displayed. This must be changed to a choice or you cannot press 🅾️ to continue. This is done as a safety to make sure you don't accidentally skip over the dialog window's query or information.

Memory location 0xE000 to 0xFFFF is being used to save the screen off prior to calling the dialog window function. Once you return from the dialog function, the screen is restored so there is no need to redraw the screen.

Some examples are:

And that's it !

It is 14-lines of code or 636-coded tokens or 1232 typed characters.

Feel free to make use of this in your own code and - when I finally finish my other project, this function will be included in it to return information back to the player on changing conditions and settings.