#!/usr/bin/env python
""" observe.py
Copyright (C) 1998,1999 Aloril
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
"""
from event import *
from ext_mind import ext_mind
import defworld
class observe(ext_mind):
def __init__(self, remote, invoke_steps=1, type="god_body", ccode=None):
ext_mind.__init__(self,"Observer",remote,invoke_steps,type,ccode=ccode)
self.make_id=1
#BEGIN mapeditor section
def load_default(self):
defworld.default(self)
def make(self, id, **kw):
mid=kw.get('desc','some thing')+" ("+self.id+"_"+`self.make_id`+")"
kw['desc']=mid
self.make_id=self.make_id+1
et=apply(ething,(id,),kw)
self.send_events([event('make',what=et)])
t=None
while not t:
self.step()
res=self.receive_events()
for e in res:
if e.command=="sight" and hasattr(e.what,"is_event"):
e2=e.what
if e2.command=="make" and hasattr(e2.what,"is_thing"):
d=e2.what.desc
if d==mid:
t=self.map.things[e2.what.id]
output=self.analyse_input(res)
self.send_events(output)
return t
#END mapeditor section
if __name__=="__main__":
obs=observe(1,0)
obs.load_default()
obs.dsp(1000000)
               (
geocities.com/siliconvalley/station/4279)                   (
geocities.com/siliconvalley/station)                   (
geocities.com/siliconvalley)