In this sample code, passing object method b.prt (of class B) will crash
Syntax: Select all
from Source import ClientCmd
class A(object):
def __init__(self, x):
self.x = x
def __call__(self, entity, command):
print(self.x)
return ClientCmd.ClientCommandReturn.CONTINUE
class B(object):
def __init__(self, x):
self.x = x
def prt(self, entity, command):
print(self.x)
return ClientCmd.ClientCommandReturn.CONTINUE
def C(entity, command):
print("C")
return ClientCmd.ClientCommandReturn.CONTINUE
a = A("A")
b = B("B")
clientcmd = ClientCmd.GetClientCommand("test")
def load():
clientcmd.AddToEnd(a)
clientcmd.AddToEnd(b.prt)
clientcmd.AddToEnd(C)
def unload():
clientcmd.Remove(a)
clientcmd.Remove(b.prt)
clientcmd.Remove(C)