Jump to content
Korean Random
Sign in to follow this  
chrkabes

Python - Связь с AS3 / Хук Метода / Доступ к полю

Recommended Posts

Всем привет, интересует ряд таких вопросов

 

1. Как получить доступ к полю из Python'a - кнопка например #angar:button/battle(пример), кнопка "В бой!", как мне собственно получить доступ к стрингу этому из питона?

 

2. Как мне хукнуть метод? - Пример onKickedFromBattle, как мне дополнить этот метод, что бы после кика из боя, выводился дополительно print("kicked"+reason) reason как аргумент в onKickedFromBattle.

 

3. Из первого, если нельзя получить доступ к полю, то как тогда осуществить связь между Python-AS3? что бы я мог из AS3 получить какие то поля...?

  • Downvote 1

Share this post


Link to post

Short link
Share on other sites

2:

oldMethod = originalMethod

def newMethod(args...):
    #print или еще что то
    return oldMethod(args...)

originalMethod = newMethod

Share this post


Link to post

Short link
Share on other sites

UP

Ожидаю ответов на вопросы?

Может ли кто нибудь привести мне пример реализации этого?

 

oldMethod = originalMethod
 

def newMethod(args...):
        #print или еще что то
        return oldMethod(args...)
 

originalMethod = newMethod
Edited by chrkabes
  • Downvote 2

Share this post


Link to post

Short link
Share on other sites
onKickedFromBattle()

Что-то я такого метода не нахожу, есть onKickedFromArena(self, reasonCode), или вот onKickedFromServer(self, reason, isBan, expiryTime)

 

Или ты хочешь понять как вообще делать хук?

# например для PlayerAvatar.onKickedFromServer(self, reason, isBan, expiryTime)

hooked_onKickedFromServer = PlayerAvatar.onKickedFromServer #сохраняем оригинальный метод

def hook_onKickedFromServer(self, reason, isBan, expiryTime): #создаём наш метод
    #тут наш код
    return hooked_onKickedFromServer(self, reason, isBan, expiryTime) #оригинальный метод

PlayerAvatar.onKickedFromServer = hook_onKickedFromServer #подмена на наш метод

или так

def hook_onKickedFromServer(self, reason, isBan, expiryTime): #создаём наш метод
    hooked_onKickedFromServer(self, reason, isBan, expiryTime) #оригинальный метод
    #тут наш код

hooked_onKickedFromServer = PlayerAvatar.onKickedFromServer #сохраняем оригинальный метод
PlayerAvatar.onKickedFromServer = hook_onKickedFromServer #подмена на наш метод

Это хотел?

Edited by Megagrob

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...