[Reality] Where is stuff?

Glyph Lefkowitz glyph@twistedmatrix.com
Sat, 18 Mar 2000 19:00:51 -0500 (EST)


On Sat, 18 Mar 2000, Michael Dartt wrote:

> Maybe it's b/c I'm tired, but I'm having trouble finding out what,
> exactly, I can do with a player, esp. the following functions: hears(),
> he(), him(), etc.  Where can I find this out?  I didn't see them in the
> User class.  Also, where should I put the code for determining whether or
> not the social exists?  I assume it should go in core.Sentence, along with
> the verb stuff, but I'm not exactly sure what to have it check.  And,
> shall I add the creation of the socials in the initialization of the
> reality?

Perhaps the source of your confusion is that there is no such thing as a
"player".  A player is just a Thing that happens to be connected to a User
(a User being an authentication object, not something that has to do with
the game directly, except for controlling and recieving input...)

> On another note, are we trying to win an obfuscated Python contest?  I
> popped open PlayerSayHandler.py, and all I saw was:

Mike, just read core.py; the documentation isn't great, but the python
certainly isn't obfuscated.  A cursory glance through the event handling
code (even just searching or grepping for "event" in core.py) would have
revealed the following;

> def event(ev,th):
> 	th.hears(ev.origin,' says, "',ev.data,'".')
> 
> "th"?  What kind of thing is that?  Looks like a player, but I haven't
> seen any comments, or any documented references....

core.py:597

	def handleEvent(self,event,data=None,origin=None,delay=0):
		"Handle an event on this object, if a proper handler exists."
		if delay:
			dl = DelayedEvent(event,data,origin,self,delay)
			self.getReality().insertEvent(dl)
		else:
			x=self.getHandler(event)
			if not x is None:
				e=Event(event,data,origin)
				x.event(e,self)
				^^^^^^^^^^^^^^^

I will give you one guess as to what type the object 'self' is in that
context.

                      ______      __   __  _____  _     _
                     |  ____ |      \_/   |_____] |_____|
                     |_____| |_____  |    |       |     |
                     @ t w i s t e d m a t r i x  . c o m
                     http://www.twistedmatrix.com/~glyph/