Background for Skyrim SE

The SkyMessage Script

    The SkyMessage script is a part of Skyrim SE’s Papyrus scripting ecosystem. This script is not present in the vanilla game, but can be found in modded sources like Papyrus MessageBox (MessageBox).

    For this script, the Papyrus index knows about:

    • 8 functions


    Inheritance Tree

    No indexed scripts extend this script.

    Properties

    No properties found.

      Events

        No events found.

      Functions

      • voidfunctionDelete(intmessageBoxId)NativeGlobal

        VS Code has a bug where the documentation of the first function isn't shown.
        This is that function:

      • stringfunctionShow(stringbodyText, stringbutton1, stringbutton2="", stringbutton3="", stringbutton4="", stringbutton5="", stringbutton6="", stringbutton7="", stringbutton8="", stringbutton9="", stringbutton10="", boolgetIndex=false, floatwaitInterval=0.1, floattimeoutSeconds=0.0)Global

        Open a messagebox and return the name of the selected button.

        Get name of selected button

        string selectedButtonName = SkyMessage.Show("body text of message", "Ok", "Cancel", "More buttons...")
        

        Get index of selected button

        If you would prefer to get the int index of the button:

        string selectedButtonIndex = SkyMessage.Show("body text of message", "Ok", "Cancel", "More buttons...", getIndex = true)
        

        Button names

        Show() accepts up to 10 button names. If you would prefer to specify the button names via an array, see: SkyMessage.ShowArray()

        Advanced

        You can also specify a timeout. This is the number of seconds after which the function will return with the text "TIMED_OUT":

        string selectedButtonName = SkyMessage.Show("body text of message", "Ok", "Cancel", "More buttons...", timeoutSeconds = 69.0)
        
      • stringfunctionShowArray(stringbodyText, string[]buttons, boolgetIndex=false, floatwaitInterval=0.1, floattimeoutSeconds=0.0)Global

        Open a messagebox and return the name of the selected button, given a string array of button names.

        Useful for when you are not hard-coding the names of the buttons!

        Button names

        Any string array should work for button names.

        string[] buttons = new string[2]
        buttons[0] = "Ok"
        buttons[1] = "Cancel"
        

        Get name of selected button

        string selectedButtonName = SkyMessage.Show("body text of message", buttons)
        

        Get index of selected button

        If you would prefer to get the int index of the button:

        string selectedButtonIndex = SkyMessage.Show("body text of message", buttons, getIndex = true)
        

        Advanced

        You can also specify a timeout. This is the number of seconds after which the function will return with the text "TIMED_OUT":

        string selectedButtonName = SkyMessage.Show("body text of message", buttons, timeoutSeconds = 69.0)
        
      • intfunctionShow_NonBlocking(stringbodyText, stringbutton1, stringbutton2="", stringbutton3="", stringbutton4="", stringbutton5="", stringbutton6="", stringbutton7="", stringbutton8="", stringbutton9="", stringbutton10="")NativeGlobal

        This created a messagebox, displays it, and returns immediately (while the message is still being displayed on the screen)

        To discover when the player has selected an option, you are expected to 'poll' using the function IsMessageResultAvailable:

        Example

        int messageBoxId = SkyrMessage.Show_NonBlocking("body text", "button 1", "button 2", ...)
        while ! SkyMessage.IsMessageResultAvailable(messageBoxId)
          Utility.WaitMenuMode(1.0)
        endWhile
        

        Once IsMessageResultAvailable returns true, you can then find out which option the player selected via GetResultText() or GetResultIndex()

        Get name of selected button

        string buttonName = SkyMessage.GetResultText(messageboxId)
        

        Get index of selected button

        string buttonIndex = SkyMessage.GetResultIndex(messageboxId)
        

        Gotcha!

        After calling either GetResultText() or GetResultIndex(), the messageBoxId will become invalid, so you cannot get BOTH the index and the text. Unless you use deleteResultOnAccess = false

        ; Get the index -but- keep the messageBoxId valid!
        string buttonIndex = SkyMessage.GetResultIndex(messageboxId, deleteResultOnAccess = false)
        
        ; So now you can get the name as well
        string buttonName = SkyMessage.GetResultText(messageboxId)
        

        If you ever have a reason to delete the messageBoxId without getting the result, you can call SkyMessage.Delete(messageBoxId)

      • intfunctionShowArray_NonBlocking(stringbodyText, string[]buttons)NativeGlobal

        This created a messagebox, displays it, and returns immediately (while the message is still being displayed on the screen)

        To discover when the player has selected an option, you are expected to 'poll' using the function IsMessageResultAvailable:

        Useful for when you are not hard-coding the names of the buttons!

        Button names

        Any string array should work for button names.

        string[] buttons = new string[2]
        buttons[0] = "Ok"
        buttons[1] = "Cancel"
        

        Example

        int messageBoxId = SkyrMessage.Show_NonBlocking("body text", buttons)
        while ! SkyMessage.IsMessageResultAvailable(messageBoxId)
          Utility.WaitMenuMode(1.0)
        endWhile
        

        Once IsMessageResultAvailable returns true, you can then find out which option the player selected via GetResultText() or GetResultIndex()

        Get name of selected button

        string buttonName = SkyMessage.GetResultText(messageboxId)
        

        Get index of selected button

        string buttonIndex = SkyMessage.GetResultIndex(messageboxId)
        

        Gotcha!

        After calling either GetResultText() or GetResultIndex(), the messageBoxId will become invalid, so you cannot get BOTH the index and the text. Unless you use deleteResultOnAccess = false

        ; Get the index -but- keep the messageBoxId valid!
        string buttonIndex = SkyMessage.GetResultIndex(messageboxId, deleteResultOnAccess = false)
        
        ; So now you can get the name as well
        string buttonName = SkyMessage.GetResultText(messageboxId)
        

        If you ever have a reason to delete the messageBoxId without getting the result, you can call SkyMessage.Delete(messageBoxId)

      • stringfunctionGetResultText(intmessageBoxId, booldeleteResultOnAccess=true)NativeGlobal

        Returns the result text from a message box created using Show_NonBlocking() or ShowArray_NonBlocking()

        If IsMessageResultAvailable is false or the messageBoxId is invalid, this returns ""
        else it returns the name of the button which was selected.

        Note: calling this function cleans up the stored messageBox and it will no longer be available
        unless you pass deleteResultOnAccess = false

      • intfunctionGetResultIndex(intmessageBoxId, booldeleteResultOnAccess=true)NativeGlobal

        Returns the result index from a message box created using Show_NonBlocking() or ShowArray_NonBlocking()

        If IsMessageResultAvailable is false or the messageBoxId is invalid, this returns -1
        else it returns the int index of the button which was selected.

        Note: calling this function cleans up the stored messageBox and it will no longer be available
        unless you pass deleteResultOnAccess = false

      • boolfunctionIsMessageResultAvailable(intmessageBoxId)NativeGlobal

        Returns true if a messagebox created via Show_NonBlocking() or ShowArray_NonBlocking() has had a button selected.
        Returns false in all other scenarios.

      Some data provided by the Skyrim Creation Kit Wiki. Licensed under the Creative Commons Attribution-ShareAlike license.