Log In  

(v02 07-21-22)

Cart #dialog-2 | 2022-07-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
3

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

VVHAT'S NEW ?

  • Updated demo slightly.

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.

.

if error==3 then
  dialog("the data table you just pasted from clipboard does not have the proper opening header for interpretation.")
  return
end

.

pal(13,12+128)
dialog("this @012 is what the boss looks like.","alert!","gotcha",10,"0,1,13,12")

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:

dialog("are you sure you want to exit without saving?",nil,"yep,not yet",13)
-- ^ this will display the dialog with "notice" title, icon #13, and default color set.
There are 2 possible string results returned from the function and they are "Y" for "yep" and "N" for "not yet."

dialog("you have made top score! congratulations!","well done","i'm the best",15,"0,4,9,10"
-- ^ this will display the dialog with "well done" for title, one choice, "i'm the best", icon #15 to appear in the top-right-hand corner of the frame, and use a custom color set of 0, 4, 9, and 10.
Only one result will return from the function of "I" from "i'm the best" as it is the only choice.

dialog("the data table you just pasted from clipboard does not have the proper opening header for interpretation.")
-- ^ this will display the dialog with "notice" title, one default choice of, "okay", no icon, and default color set.

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.

P#114621 2022-07-21 23:51 ( Edited 2022-07-22 01:21)


[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2022-11-27 15:36:47 | 0.100s | Q:16