def at_object_receive(self, new_arrival, source_location): """ When an object enters a room we tell other objects in the room about it by trying to call a hook on them. The Mob object uses this to cheaply get notified of enemies without having to constantly scan for them. Args: new_arrival (Object): the object that just entered this room. source_location (Object): the previous location of new_arrival. """ if self.tags.get( 'rp', category='flags') and not new_arrival.attributes.has('_sdesc'): sdesc = self.db.messages and self.db.messages.get( 'species') or new_arrival.key new_arrival.sdesc.add(sdesc) if new_arrival.has_account: # and not new_arrival.is_superuser: # this is a character if self.tags.get('weather', category='flags'): if not self.nattributes.has('weather_time'): self.attempt_weather_update( 1.00) # 100% chance of update on initial arrival. tickers = TICKER_HANDLER.all_display() counter = 0 for tick in tickers: if tick[0] == self and tick[1] == 'update_weather': notice = '' counter += 1 show = '20%% chance every %s seconds in ' % tick[3] show += "%s%s" % ( tick[0] or "[None]", tick[0] and " (#%s)" % (tick[0].id if hasattr(tick[0], 'id') else '') or '') if counter > 1: notice = '|rExtra Ticker|n - |yadditional|n ' # TODO: Too many weather tickers going, maybe remove extra? channel = ChannelDB.objects.channel_search('MudInfo') if channel[0]: channel[0].msg( '* %s\'s %s experience * %s%s' % (new_arrival.key, tick[4], notice, show), keep_log=False) if counter == 0: # No weather ticker! Add a weather ticker. interval = random.randint(12, 30) * 10 TICKER_HANDLER.add(interval=interval, callback=self.update_weather, idstring='Weather') for obj in self.contents_get(exclude=new_arrival): if hasattr(obj, 'at_new_arrival'): obj.at_new_arrival(new_arrival)
def func(self): from evennia import TICKER_HANDLER all_subs = TICKER_HANDLER.all_display() if not all_subs: self.caller.msg("No tickers are currently active.") return table = EvTable("interval (s)", "object", "path/methodname", "idstring", "db") for sub in all_subs: table.add_row(sub[3], "%s%s" % (sub[0] or "[None]", sub[0] and " (#%s)" % (sub[0].id if hasattr(sub[0], "id") else "") or ""), sub[1] if sub[1] else sub[2], sub[4] or "[Unset]", "*" if sub[5] else "-") self.caller.msg("|wActive tickers|n:\n" + unicode(table))
def func(self): from evennia import TICKER_HANDLER all_subs = TICKER_HANDLER.all_display() if not all_subs: self.caller.msg("No tickers are currently active.") return table = EvTable("interval (s)", "object", "path/methodname", "idstring", "db") for sub in all_subs: table.add_row(sub[3], "%s%s" % (sub[0] or "[None]", sub[0] and " (#%s)" % (sub[0].id if hasattr(sub[0], "id") else "") or ""), sub[1] if sub[1] else sub[2], sub[4] or "[Unset]", "*" if sub[5] else "-") self.caller.msg("|wActive tickers|n:\n" + unicode(table))
def at_object_receive(self, new_arrival, source_location): """ When an object enters a room we tell other objects in the room about it by trying to call a hook on them. The Mob object uses this to cheaply get notified of enemies without having to constantly scan for them. Args: new_arrival (Object): the object that just entered this room. source_location (Object): the previous location of new_arrival. """ if new_arrival.has_player: # and not new_arrival.is_superuser: # this is a character outdoor = self.tags.get('outdoor', category='flags') if outdoor: tickers = TICKER_HANDLER.all_display() counter = 0 for tick in tickers: if tick[0] == self and tick[1] == 'update_weather': notice = '' counter += 1 show = '20%% chance every %s seconds in ' % tick[3] show += "%s%s" % ( tick[0] or "[None]", tick[0] and " (#%s)" % (tick[0].id if hasattr(tick[0], "id") else "") or "") if counter > 1: notice = '|rExtra Ticker|n - |yadditional|n ' # Too many weather tickers going, maybe remove extra? channel = ChannelDB.objects.channel_search('MudInfo') if channel[0]: channel[0].msg( '* %s\'s %s experience * %s%s' % (new_arrival.key, tick[4], notice, show), keep_log=False) if counter == 0: # No weather ticker - add one. interval = random.randint(50, 70) TICKER_HANDLER.add(interval=interval, callback=self.update_weather, idstring='Weather') for obj in self.contents_get(exclude=new_arrival): if hasattr(obj, "at_new_arrival"): obj.at_new_arrival(new_arrival)
def at_object_receive(self, new_arrival, source_location): """ When an object enters a room we tell other objects in the room about it by trying to call a hook on them. The Mob object uses this to cheaply get notified of enemies without having to constantly scan for them. Args: new_arrival (Object): the object that just entered this room. source_location (Object): the previous location of new_arrival. """ if self.tags.get('rp', category='flags') and not new_arrival.attributes.has('_sdesc'): sdesc = self.db.messages and self.db.messages.get('species') or new_arrival.key new_arrival.sdesc.add(sdesc) if new_arrival.has_account: # and not new_arrival.is_superuser: # this is a character if self.tags.get('weather', category='flags'): if not self.nattributes.has('weather_time'): self.attempt_weather_update(1.00) # 100% chance of update on initial arrival. tickers = TICKER_HANDLER.all_display() counter = 0 for tick in tickers: if tick[0] == self and tick[1] == 'update_weather': notice = '' counter += 1 show = '20%% chance every %s seconds in ' % tick[3] show += "%s%s" % (tick[0] or "[None]", tick[0] and " (#%s)" % (tick[0].id if hasattr(tick[0], 'id') else '') or '') if counter > 1: notice = '|rExtra Ticker|n - |yadditional|n ' # TODO: Too many weather tickers going, maybe remove extra? channel = ChannelDB.objects.channel_search('MudInfo') if channel[0]: channel[0].msg('* %s\'s %s experience * %s%s' % (new_arrival.key, tick[4], notice, show), keep_log=False) if counter == 0: # No weather ticker! Add a weather ticker. interval = random.randint(12, 30) * 10 TICKER_HANDLER.add(interval=interval, callback=self.update_weather, idstring='Weather') for obj in self.contents_get(exclude=new_arrival): if hasattr(obj, 'at_new_arrival'): obj.at_new_arrival(new_arrival)
def at_object_receive(self, new_arrival, source_location): """ When an object enters a room we tell other objects in the room about it by trying to call a hook on them. The Mob object uses this to cheaply get notified of enemies without having to constantly scan for them. Args: new_arrival (Object): the object that just entered this room. source_location (Object): the previous location of new_arrival. """ if new_arrival.has_player: # and not new_arrival.is_superuser: # this is a character outdoor = self.tags.get('outdoor', category='flags') if outdoor: tickers = TICKER_HANDLER.all_display() counter = 0 for tick in tickers: if tick[0] == self and tick[1] == 'update_weather': notice = '' counter += 1 show = '20%% chance every %s seconds in ' % tick[3] show += "%s%s" % (tick[0] or "[None]", tick[0] and " (#%s)" % (tick[0].id if hasattr(tick[0], "id") else "") or "") if counter > 1: notice = '|rExtra Ticker|n - |yadditional|n ' # Too many weather tickers going, maybe remove extra? channel = ChannelDB.objects.channel_search('MudInfo') if channel[0]: channel[0].msg('* %s\'s %s experience * %s%s' % (new_arrival.key, tick[4], notice, show), keep_log=False) if counter == 0: # No weather ticker - add one. interval = random.randint(50, 70) TICKER_HANDLER.add(interval=interval, callback=self.update_weather, idstring='Weather') for obj in self.contents_get(exclude=new_arrival): if hasattr(obj, "at_new_arrival"): obj.at_new_arrival(new_arrival)