Skip to content

Class "GenericPrompt"⚓︎

Info

You can get this class by using its constructor or using the following functions:

Example Code

This code creates a generic popup that opens when pressing the "Minus"-button. It prints the selected option to the console and displays some dummy text.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local myPrompt = GenericPrompt()
myPrompt:Initialize()
myPrompt:SetText("Some test text")

local wasPromptDisplayed = false

function mod:myRenderFunction(_)
    myPrompt:Render()
end 
mod:AddCallback(ModCallbacks.MC_POST_RENDER, mod.myRenderFunction)

function mod:myUpdateFunction(_) 
    myPrompt:Update(true) -- true = Process user inputs
    if wasPromptDisplayed and not myPrompt:IsActive() then -- prompt was closed by user 
        print("User selected option: "..myPrompt:GetSubmittedSelection()) 
        wasPromptDisplayed = false 
    end
    if Input.IsButtonTriggered(Keyboard.KEY_MINUS, 0)  then -- on Pressing minus button will open prompt 
        myPrompt:Show() 
        wasPromptDisplayed = true 
    end 
end 
mod:AddCallback(ModCallbacks.MC_POST_UPDATE, mod.myUpdateFunction)

Constructors⚓︎

GenericPrompt ()⚓︎

GenericPrompt GenericPrompt ( )⚓︎

Returns a GenericPrompt object. Allows for rendering a popup paper with the option to include text and tracking input for a yes/no decision.

Functions⚓︎

GetCurrentSelection ()⚓︎

int GetCurrentSelection ( )⚓︎

Returns what selection the player is currently hovering over.

Return info
  • 0 - No
  • 1 - Yes

GetSprite ()⚓︎

Sprite GetSprite ( )⚓︎

Returns the paper sprite of the prompt.


GetSubmittedSelection ()⚓︎

int GetSubmittedSelection ( )⚓︎

Returns the chosen selection.

Return info
  • 0 - None (Returns if the player dismisses the prompt).
  • 1 - Yes
  • 2 - No

Initialize ()⚓︎

void Initialize ( boolean SmallPrompt = false )⚓︎


IsActive ()⚓︎

boolean IsActive ( )⚓︎

Returns whether the prompt is active or not.


Render ()⚓︎

void Render ( )⚓︎

Renders the prompt on-screen. Place this in any of the non-entity-specific RENDER callbacks.


SetText ()⚓︎

void SetText ( string Text1 = "", string Text2 = "", string Text3 = "", string Text4 = "", string Text5 = "", )⚓︎

Set text that will appear on the paper.

Text strings are associated with their position on the prompt from top to bottom. The first two strings should used as header text, being bolded and at a higher font size, while the rest as description text.


Show ()⚓︎

void Show ( )⚓︎

Starts showing the prompt on-screen.


Update ()⚓︎

void Update ( boolean ProcessInput )⚓︎

Updates the animation of the prompt paper. Set ProcessInput to true to track the player's input for selecting yes/no, false otherwise.