Notifications
Goals
Show a message to the player that pops up on the lower right of the screen. It can be a message that disappears after some time is elapsed or a message that stays visible until it is dismissed by completing some objective in the game.
How it works
Regular Messages
Use the notification_requested
event to send your notifications!
This event needs three parameters, the message itself, the type of message, and the duration it should be displayed for before being dismissed. ex:
Events.emit_signal("notification_requested", "Hello World", "warning", 3)
The code above will make a notification pop up in the lower right of the game's window saying "Hello World", it will stay visible for 3 seconds and then hide.
You can also send -1
in the duration to make it stay on screen permanently. Then, you'll need to later dismiss it manually by sending the notification_dismissed
event:
Events.emit_signal("notification_dismissed")
Valid Message Types
Message "types" change the icon that is displayed to the left of the notification. You must send a string in the event and valid options are:
- "success" - uses a checkmark as icon
- "warning" - uses an exclamation mark as icon
- "failure" - uses a "x" as icon
- "" (or any other string) - uses an "i" as icon
"Special" Messages
These are used when we need to create messages that have button prompts or any other special requirements.
How to add a new "Special" Notification
- Create a and format the message as you want, inside the Notifications scene. If it has any Button Prompts, make sure to add the correct "action" to it in the inspector.
- Make sure to add the Label to the group
special_prompt_label
. - Add a constant with the Node Name of the new prompt.
How to use special prompts
You send the event notification_special_requested
, which has the same three parameters as a regular notification.
Events.emit_signal(
"notification_special_requested",
Notifications.SPECIAL_PROMPT_ROLL,
"warning",
-1
)
The "type" and "duration" parameters work the same. In the "message" parameter you must send the name of the Node that should be visible, that's why having the constants are useful as they serve as an autocomplete for which special notifications are available.
With what script it communicates
No external scripts. Other scripts communicate with this one through Event signals.