好吧,所以我正在为迪斯尼的关闭游戏Toontown在线制作一个服务器,但是我在添加了这个代码之后遇到了一个问题。游戏需要这一部分,它对游戏至关重要,没有它,游戏就不会发送客户端,”AvatarChooser.enter.输入“玩家将无法创造他们的角色!如果需要的话,我会把更多的代码放出来,但这只是暂时的。在
class DistributedDistrict(DistributedObject):
__module__ = __name__
notify = directNotify.newCategory('DistributedDistrict')
neverDisable = 1
def __init__(self, cr):
print 'DistributedDistrict: BlankTest Canvas is now Online..'
DistributedObject.__init__(self, cr)
self.name = 'BlankTest Canvas'
self.available = 0
self.avatarCount = 0
self.newAvatarCount = 0
def announceGenerate(self):
DistributedObject.announceGenerate(self)
self.cr.activeDistrictMap[self.doId] = self
messenger.send('shardInfoUpdated')
def delete(self):
if base.cr.distributedDistrict is self:
base.cr.distributedDistrict = None
if self.cr.activeDistrictMap.has_key(self.doId):
del self.cr.activeDistrictMap[self.doId]
DistributedObject.delete(self)
messenger.send('shardInfoUpdated')
return
def setAvailable(self, available):
self.available = available
messenger.send('shardInfoUpdated')
def setName(self, name):
self.name = name
messenger.send('shardInfoUpdated')
simbase = DistributedDistrict()
#run() # Initialize the Panda3D API.
我得到这个错误:
TypeError: __ init __() takes exactly 2 arguments (1 given)
如有任何帮助,我们将不胜感激!!在
错误发生在:
^{pr2}$
当谈到分布式对象(在本例中是一个DistributedDistrict)时,您需要检查DistributedClass文件,看看它实际包含哪些字段,在这个文件中,您会发现它看起来像这样(如果您想自己查看它的话)otp.dc.公司在你的toontown目录中)
在这里,您可以看到您在代码中呈现的2个字段,现在您只需将您的
^{pr2}$ClientRepository
提供给此代码,您还需要查看这个DistributedObject
是否有它的AI或UD(UberDOG)表示。你可以通过(再)看看otp.dc.公司在{{AI}实际上是由cd2生成的。这意味着服务器是该对象的所有者,只有服务器才能设置值setName和setAvailable。为了使它正确运行,你需要写一些东西来接收由普通的
DistributedDistrict.py
文件发送的更新,这个新的AI文件必须被称为DistributedDistrictAI.py
,并且必须在AIRepository中创建为一个新的DistributedObject。事实上,它也是一个超级狗也意味着你需要写一个D分布分布图.py然后应该在UDRepository上创建的DistributedObject的表示形式。在希望这能给你指明正确的方向,祝你的项目好运。在
不应将其设置为
5
。cr
参数需要一个ClientRepository参数。在请注意这一行中参数的数量:
现在,看看
^{pr2}$DistributedDistrict
的构造函数:self
隐含在构造函数中,但您忘记了cr
参数。在要解决此问题,您需要:
相关问题 更多 >
编程相关推荐