本文整理汇总了Python中evennia.TICKER_HANDLER.all_display方法的典型用法代码示例。如果您正苦于以下问题:Python TICKER_HANDLER.all_display方法的具体用法?Python TICKER_HANDLER.all_display怎么用?Python TICKER_HANDLER.all_display使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类evennia.TICKER_HANDLER
的用法示例。
在下文中一共展示了TICKER_HANDLER.all_display方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: func
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import all_display [as 别名]
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))
示例2: at_object_receive
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import all_display [as 别名]
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)
示例3: at_object_receive
# 需要导入模块: from evennia import TICKER_HANDLER [as 别名]
# 或者: from evennia.TICKER_HANDLER import all_display [as 别名]
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)