Notification

From wiki
Jump to: navigation, search

In Staxel, *.notification files are used to specify everything about notifications. These notifications are those small boxes that appear when something happens.

  • The size and look of the box
  • Sounds played, how long it stays up.
  • Whether multiple can be shown, and what translation code should they look for.

These notifications are often used alongside lines of code which change what the translation line is supposed to show.

Creating a *.notification file

Notifications actually don't use any other files, except Sound files, listed on this wiki. In essence a notification can be easily made, without the need to look up many other pages on this wiki. A full file might look like;

{
  "kind" : "staxel.notifications.general",
  "box" : "staxel/notifications/NotificationBox.png",
  "boxDimensions" : { "x" : 244.0, "y" : 82.5 },
  "displayTime" : 3000,
  "icon" : "",
  "translationCode" : "",
  "sticky" : false,
  "allowMultiple" : false,
  "soundEffect" : ""
}

Though if you want to simply copy the rest of the notifications in staxel, only the following would be needed;

{
  "__inherits" : "staxel/notifications/GeneralNotification.config",
  "code" : "staxel.notifications.AchievementUnlocked",
  "translationCode" : "achievements.achievementUnlocked",
  "icon" : "staxel/notifications/icons/AchievementIcon.png"
}

The code and icon properties should be fairly self explanatory. The translation code, however, leads to a line that you can use to Translate the line. You'll need to provide a language file in order to provide what text will actually shown. With all that you have a notification that can be displayed, and it will also show text as long as you have made a translation file for that.


Config Options

"code"

Valid options (String): A unique string which Notification this object is.

Default Value: No default value is specified. Always need to provide your own.


A string containing the code of the Notification the blob will be referring to.


"kind"

Valid options (String): A string representing what kind of Notification this is.

Default Value: No default value is specified. Always need to provide your own.


A string that is used by Staxel to provide the correct information. Currently only two kinds are used; "staxel.notifications.general" the normal notification and "staxel.notifications.itemReceived" which is a notification for collecting items. In most cases the general kind is sufficient.


"allowMultiple"

Valid options (Bool): Either True or False

Default Value: If not specified, will default to False.


This determines whether or not the notification will allow multiple copies of itself to show. Useful for notifications that might get spammed. (Like trying to sleep in a bed or buying something you can't buy.


"box"

Valid options (String): A string which contains the path to the an image.

Default Value: No default value is specified. Always need to provide your own.


This is the image of the box shown underneath the text and image.


"boxDimensions"

Valid options (Vector 2 - Float): { "x" : 0.0, "y" : 0.0}

Default Value: No default value is specified. Always need to provide your own.


This specifies how large the box should be. This should be roughly the same size as the image used in the box property, but does not need to be.


"displayTime"

Valid options (Integer): An int which contains the time in milliseconds.

Default Value: If not specified, will default to 3 seconds. (3000 milliseconds)


This is how long the notification will show for.


"icon"

Valid options (String): A string which contains the path to the an image.

Default Value: If not specified, will not show an icon along with the achievement.


This is the image shown alongside the text to help contextualise the notification.


"soundEffect"

Valid options (String): A string which points to a Sound code.

Default Value: If not specified, will not play a sound along with the achievement.


This is the sound effect that the notification can play when it appears.


"sticky"

Valid options (Bool): Either True or False

Default Value: If not specified, will default to False.


This determines whether or not the notification will stay up unless it is told to be hidden, probably via code.


"textAreaWidth"

Valid options (Float): A positive decimal number

Default Value: No default value is specified. Always need to provide your own.


This is how wide the text box on the achievement will be. Most achievements will be 160 pixels wide, but some achievements may be larger than this in order to fit more text.


"translationCode"

Valid options (String): A string which should not conflict with any other translation string

Default Value: If not specified, will not show text alongside the notification


This is the code to the translation, that is the text, that should be shown on the notification.