"When I set it to five it worked"
You should NOT set it to 5
. The cr
argument expects a ClientRepository argument.
Question
Alright, so i'm making a server for Disney's now closed game Toontown Online, But i have run into a problem after i added this coding in. The game NEEDS this part, it is essential to the game, without it, the game will not send the client, "AvatarChooser.enter" and players wont be able to create their Characters! I will put more code out if needed, but this for now.
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.
I get this error:
TypeError: __ init __() takes exactly 2 arguments (1 given)
Any help would be glady appreciated!!
Error happens at:
simbase = DistributedDistrict()
#run() # Initialize the Panda3D API.
No correct solution
OTHER TIPS
"When I set it to five it worked"
You should NOT set it to 5
. The cr
argument expects a ClientRepository argument.
Note the amount of arguments in this line:
simbase = DistributedDistrict()
Now, look at the constructor for DistributedDistrict
:
def __init__(self, cr):
The self
is implied in the constructor, but you forgot the cr
argument.
To fix this, you want:
simbase = DistributedDistrict(some_value) # wasn't sure what the value of cr would be
When talking about distributed objects (in this case a DistributedDistrict) you need to check in the DistributedClass file to see what fields it actually takes, in this you'll find that it looks like this (if you want to see this yourself look in otp.dc in your toontown directory)
dclass DistributedDistrict : DistributedObject {
setName(string) required broadcast ram;
setAvailable(uint8) required broadcast ram;
here you can see the 2 fields that you are presenting in your code, now while you can just provide your ClientRepository
to this code, you also need to look at if this DistributedObject
has an AI or an UD (UberDOG) representation of it. You can figure this out by (again) looking at otp.dc
from otp.distributed import DistributedDistrict/AI/UD
Here you can see that DistributedDistrict
is actually a DistributedObject
that is generated by the AI server. This means that the server is the owner of this object and that nobody but the server can set the value setName and setAvailable. In order to have this running correctly you need to write something to receive the updates that are sent by the normal DistributedDistrict.py
file, this new AI file must be called DistributedDistrictAI.py
and must be created as a new DistributedObject in the AIRepository. The fact that it is also an UberDOG also means that you need to write a DistributedDistrictUD.py representation of the DistributedObject which should then be created on your UDRepository.
Hope this points you in the right direction, good luck with your project.