Jump to content
Korean Random
Sign in to follow this  
ahwa

0.9.17.3 PlayerAvatar.handleKey Не работает?

Recommended Posts

import Keys
import Avatar

 

ModEnable = True

 

def New_PlayerAvatar(current, isDown, key, mods):
    global ModEnable
 

    if ModEnable and key == Keys.KEY_NUMPAD0 and isDown:
        ModEnable = False
        message = '<font color="#FF0000">' + 'ModStop' + '</font>'
        MessengerEntry.g_instance.gui.addClientMessage(message)

    if not ModEnableand and key == Keys.KEY_NUMPAD0 and isDown:
        ModEnable= True
        message = '<font color="#7BFF00">' + 'ModStart' + '</font>'
        MessengerEntry.g_instance.gui.addClientMessage(message)
    return Old_PlayerAvatar(current, isDown, key, mods)

 

Old_PlayerAvatar = Avatar.PlayerAvatar.handleKey

Avatar.PlayerAvatar.handleKey = New_PlayerAvatar

 

Не работает Методы Ошибки?

Edited by ahwa

Share this post


Link to post

Short link
Share on other sites


import Keys
from gui import InputHandler
from gui.shared import events, g_eventBus
from gui.app_loader.settings import APP_NAME_SPACE

class HotKey(object):
def __init__(self):
    g_eventBus.addListener(events.AppLifeCycleEvent.INITIALIZING, self.battleLoading)
    g_eventBus.addListener(events.AppLifeCycleEvent.DESTROYED, self.destroyBattle)
    self.hot_key = getattr(Keys, "KEY_NUMPAD0", None)
self.enable = False

def battleLoading(self, event):
    if event.ns == APP_NAME_SPACE.SF_BATTLE:
        InputHandler.g_instance.onKeyDown += self.key_event
        InputHandler.g_instance.onKeyUp += self.key_event

def destroyBattle(self, event):
    if event.ns == APP_NAME_SPACE.SF_BATTLE:
        InputHandler.g_instance.onKeyDown -= self.key_event
        InputHandler.g_instance.onKeyUp -= self.key_event

def key_event(self, event):
    if self.hot_key is not None:
# key down event
        if event.key == self.hot_key and event.isKeyDown():
self.enable = True if not self.enabe else False
message = '<font color="#FF0000">ModStop</font>' if not self.enable else '<font color="#7BFF00">ModStart</font>'
# message = '<font color="%s">%s</font>' % (("#FF0000", "ModStop") if not self.enable else ("#7BFF00", "ModStart"))
MessengerEntry.g_instance.gui.addClientMessage(message) # import the MessengerEntry
            print 'key is Down'
# key up event
        # if event.key == self.hot_key and not event.isKeyDown():
# print 'key is UP'
HotKey()

 

Edited by Armagomen_dev

Share this post


Link to post

Short link
Share on other sites

if event.key == self.logs_altmode_key and event.isKeyDown():

 

is my key?? self.logs_altmode  change event.key == KEY_NUMPAD0

 

Or no effect

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...