@create $thing as standard
@set standard.f = 1
@set standard.interval = 300
@newfunc standard.update(self)
if time() - self.lastTime < self.interval: return
self.lastTime = time()
try: self.periodicTask()
except:
self.owner.tell("Bug in " + self.name + \
".periodicTask(). Updates stopped.")
self.wantsUpdates = 0
.x
@newfunc standard.checkPerm(self)
if user != self and user != self.owner and not user.wizard:
print self.name + " belongs to " + self.owner.name + "."
return 0
return 1
.x
@newfunc standard.start(self)
if not self.checkPerm(): return
self.wantsUpdates = 1
self.lastTime = time() - self.interval
print self.name, "started."
if user != self.owner:
self.owner.tell( user.name + " has started " + self.name + "." )
.x
@cmd standard.start <this> calls start()
@newfunc standard.stop(self)
if not self.checkPerm(): return
self.wantsUpdates = 0
print self.name, "stopped."
if user != self.owner:
self.owner.tell( user.name + " has stopped " + self.name + "." )
.x
@cmd standard.stop <this> calls stop()
@newfunc standard.periodicTask(self)
self.owner.tell( self.name + " has received a call to periodicTask()." )
.x
beam standard to $pub.periodic
@create $pub.periodic.standard as myBeeperYou can then set the timing interval by setting your object's .interval property in seconds (it defaults to 300, i.e., 5 minutes).
Start the periodic updates with a command such as start myBeeper, and stop it similarly (stop myBeeper). While it is running, you (as the owner of the object) will receive a message every time its periodic task is executed.
To make your object do something more useful, override the .periodicTask function, like this:
@newfunc myBeeper.periodicTask(self)
self.location.broadcast("You heer a beep.")
.x