Jump to content
Korean Random
Valberton

Мониторинг нации выбранного танка в ангаре в реалтайме.

Recommended Posts

Вопрос насущный таков:
Как можно мониторить нацию танка, выбранного в ангаре в реальном времени?

Share this post


Link to post

Short link
Share on other sites

@VLBRTN

from CurrentVehicle import g_currentVehicle
# OPTIONAL: in case of using vehicle.nationID
from nations import NAMES

def onVehicleChanged():
    vehicle = g_currentVehicle.item
    if vehicle is not None:
        print vehicle.nationName # One of 'ussr', 'germany', 'usa', 'china', 'france', 'uk', 'japan', 'czech', 'sweden', 'poland', 'italy'
        print vehicle.nationID   # returns index of list above
	print NAMES[vehicle.nationID] # alternative way
        # Do something else

g_currentVehicle.onChanged += onVehicleChanged

 

Edited by Kurzdor
  • Upvote 3

Share this post


Link to post

Short link
Share on other sites

Забыл, что при перезаходе на другой сервер выполняется CurrentVehicle.destroy, а он в свою очередь очищает список слушателей данного ивента, поэтому делаем так без всяких оверрайдов LobbyView.populate/подпиской на событие смены вьюхи на VIEW_ALIAS.LOBBY_HANGAR

from CurrentVehicle import g_currentVehicle
from gui.shared.personality import ServicesLocator
from skeletons.gui.app_loader import GuiGlobalSpaceID

def onVehicleChanged():
    vehicle = g_currentVehicle.item
    if vehicle is not None:
        print vehicle.nationName

def onGUISpaceEntered(spaceID, *args, **kwargs):
    if spaceID != GuiGlobalSpaceID.LOBBY:
        return
    
    g_currentVehicle.onChanged += onVehicleChanged

ServicesLocator.appLoader.onGUISpaceEntered += onGUISpaceEntered

 

  • Upvote 2

Share this post


Link to post

Short link
Share on other sites
Guest
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...