Jump to content
Korean Random
NemesiS

удалить точку с мини карты

Recommended Posts

Если я делаю так:

MinimapapEntryF3 = 0
entryIDF3 = 0

def new_handleKeyT2Makct(self, isDown, key, mods):
    HandleTheKey(self, isDown, key, mods)

    if key == pa.Key_T3 and mods == 0 and isDown:       
            battle = g_appLoader.getDefBattleApp()
            if battle:
                if pa.TyTest == 0:
                    MinimapapEntryF3 = g_appLoader.getDefBattleApp().containerManager.getContainer(ViewTypes.VIEW).getView().components['minimap']
                    if MinimapapEntryF3 is not None:
                        symbol = _S_NAME.ALLY_TEAM_SPAWN    #_S_NAME.ALLY_TEAM_SPAWN
                        container = _C_NAME.TEAM_POINTS #_C_NAME.ALIVE_VEHICLES
                        matrix = Math.Matrix()
                        vector = -77.2736, 21.9409, -22.9597
                        matrix.setTranslate(vector)
                        entryIDF3 = MinimapapEntryF3.addEntry(symbol, _C_NAME.TEAM_POINTS, matrix=matrix, active=True)
                        if entryIDF3:
                            MinimapapEntryF3.invoke(entryIDF3, 'setPointNumber', 5)
                            SoundGroups.g_instance.playSound2D(settings.MINIMAP_ATTENTION_SOUND_ID)
                            print 'add entry OK'
                            pa.TyTest = 1
                    return True
                if pa.TyTest == 1:
                    if MinimapapEntryF3 is not None:
                        pa.TyTest = 0
                        MinimapapEntryF3.delEntry(entryIDF3)
                        print 'del entry'
                        return True

получаю ошибку: UnboundLocalError: local variable 'MinimapapEntryF3' referenced before assignment

Точка ставится нормально, но если пытаюсь ее удалить вылазит эта ошибка.

Даже если сделать так:

MinimapapEntryF3 = g_appLoader.getDefBattleApp().containerManager.getContainer(ViewTypes.VIEW).getView().components['minimap']
MinimapapEntryF3.delEntry(entryIDF3)

все равно пишет: UnboundLocalError: local variable 'MinimapapEntryF3' referenced before assignment

Edited by NemesiS

Share this post


Link to post

Short link
Share on other sites
Даже если сделать так:

 

 

Почему даже. Не даже. Так как во втором случае у вас скорее всего вылазит ошибка "UnboundLocalError: local variable 'entryIDF3' referenced before assignment". А она аналогична первой ошибке и исправляется также.

Edited by StranikS_Scan
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

>получаю ошибку: UnboundLocalError: local variable 'MinimapapEntryF3' referenced before assignment

Потому что MinimapapEntryF3 = g_appLoader. есть присвоение значения локальной переменной.

Ты забыл объявить их глобальными в функции:

def new_handleKeyT2Makct(self, isDown, key, mods):
    global MinimapapEntryF3, entryIDF3

Ну или вообще сделай так:

def new_handleKeyT2Makct(self, isDown, key, mods):
    MinimapapEntryF3 = 0
    entryIDF3 = 0
    HandleTheKey(self, isDown, key, mods)
  • Upvote 1

Share this post


Link to post

Short link
Share on other sites

Точно спасибо.


И еще вопрос, если я меняю значения с:

symbol = _S_NAME.ALLY_TEAM_SPAWN 
container = _C_NAME.TEAM_POINTS

На:

symbol = _S_NAME._TUTORIAL_TARGET
container = _C_NAME.ICONS

Получаю ошибку: Exception: invokePy2As - Failed to invoke method.

Edited by NemesiS

Share this post


Link to post

Short link
Share on other sites
            if battle:
                if pa.TyTest == 0:
                    MinimapapEntryF3 = g_appLoader.getDefBattleApp().containerManager.getContainer(ViewTypes.VIEW).getView().components['minimap']

UnboundLocalError: local variable 'MinimapapEntryF3' referenced before assignment

    entryIDF3 = 0

    def new_handleKeyT2Makct(self, isDown, key, mods):
        HandleTheKey(self, isDown, key, mods)

        if key == pa.Key_T3 and mods == 0 and isDown:      
            battle = g_appLoader.getDefBattleApp()
            if battle:
                minimapapEntryF3 = battle.containerManager.getContainer(ViewTypes.VIEW).getView().components.get('minimap')
                if minimapapEntryF3:
                    if pa.TyTest == 0:
                        symbol = _S_NAME.ALLY_TEAM_SPAWN    #_S_NAME.ALLY_TEAM_SPAWN
                        container = _C_NAME.TEAM_POINTS #_C_NAME.ALIVE_VEHICLES
                        matrix = Math.Matrix()
                        vector = -77.2736, 21.9409, -22.9597
                        matrix.setTranslate(vector)
                        entryIDF3 = minimapapEntryF3.addEntry(symbol, _C_NAME.TEAM_POINTS, matrix=matrix, active=True)
                        if entryIDF3:
                            minimapapEntryF3.invoke(entryIDF3, 'setPointNumber', 5)
                            SoundGroups.g_instance.playSound2D(settings.MINIMAP_ATTENTION_SOUND_ID)
                            print 'add entry OK'
                            pa.TyTest = 1
                        return True
                    if pa.TyTest == 1:
                        pa.TyTest = 0
                        minimapapEntryF3.delEntry(entryIDF3)
                        print 'del entry'
                        return True

Ну как-то так... 

И вот это вот в начале не нужно. MinimapapEntryF3 = 0

 

 

 

Потому что MinimapapEntryF3 = g_appLoader. есть присвоение значения локальной переменной

Не он просто её не там создает в теле первого if pa.TyTest == 0:, чуть выше надо.

Edited by Armagomen_dev

Share this post


Link to post

Short link
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...