Skip to content

Notification Center

mh5001 edited this page Feb 3, 2019 · 4 revisions

What is it?

Notification center is a part of the GUI in garage. Here's how it can look like: View
And in this topic, you will learn how to send custom messages to it.

Getting started - imports

Let's import everything we need.

import BigWorld                 # the WoT engine
import functools                # will be explained
from gui import SystemMessages  # Notification center

That's everything we need.

BigWorld - The engine of World of Tanks. Needs to be imported for any WoT mod.
functools - In this example, we will need this to wait for the Notification Center to get ready.
from gui import SystemMessages - This is what we want. SystemMessages are those messages in the N. Center.

Message Types

Messages can have different icons associated with them. For a complete list, look at this image: View Image
The command for sending a message is:

SystemMessages.pushMessage("This is a message", SystemMessages.SM_TYPE.type_of_message) 

Types of messages are the following:
Error, Warning, Information, GameGreeting, PowerLevel, FinancialTransactionWithGold, FinancialTransactionWithCredits, FortificationStartUp, PurchaseForGold, DismantlingForGold, PurchaseForCredits, Selling, Remove, Repair, CustomizationForGold, CustomizationForCredits

Message about selling your favorite tank - AMX 40 - would look like this:

SystemMessages.pushMessage("AMX 40 was sold.", SystemMessages.SM_TYPE.Selling) 

Waiting for the Notification Center

Scripts are being run on the login screen. We need to wait until the player logs in and gets into his garage.

def sendMessage(message, type):
    if BigWorld.player():  # If ready to show the message
        SystemMessages.pushMessage(message, type) 
    else: 
        BigWorld.callback(1, functools.partial(sendMessage, message, type)) # Wait 1 second and try again

sendMessage("Hello World", SystemMessages.SM_TYPE.Information)

And that's it, all done! The whole code now looks like this:

import BigWorld                 
import functools               
from gui import SystemMessages  

def sendMessage(message, type):
    if BigWorld.player():  
        SystemMessages.pushMessage(message, type) 
    else: 
        BigWorld.callback(1, functools.partial(sendMessage, message, type)) 

sendMessage("Hello World", SystemMessages.SM_TYPE.Information)

All that's left to do is to compile your script and place it in res_mods/0.9.x/scripts/client/mods