def room_info(**kwargs): new = False room = kwargs['room'] room.name = room.name.replace("Flying above ","").replace("In the trees above ","") if room.id not in mapdata.rooms: new = True mapdata.add( room.id, room.name, room.area, room.environment, {int(v):k for k, v in room.exits.items()}, room.coords, room.details, room.map, new ) def ql_info(room, new): for line in sage.buffer: if line[:-1] == room.name: line.output += ansi.grey(' (%s) (%s)' % (room.area, room.id)) if new: line.output += ansi.grey(' [new]') sage.defer_to_prompt(ql_info, room, new)
def on_room_update(signal, room): def update_players(): # use of global isn't encouraged, but in this case it was a simple solution global last_room # we get room events even if we don't change rooms. eg: squinting. if player.room.id == last_room: return last_room = player.room.id write_players() # Why defer to prompt? Because GMCP data and the actual lines from Achaea don't always come # at the same time. To make sure we don't get out of sync, we defer to the prompt when # everything should be ready. sage.defer_to_prompt(update_players)
def room_info(**kwargs): new = False room = kwargs['room'] room.name = room.name.replace("Flying above ", "").replace("In the trees above ", "") if long(room.id) not in mapdata.rooms: new = True mapdata.add(long(room.id), room.name, room.area, room.environment, {int(v): k for k, v in room.exits.items()}, room.coords, room.details, room.map, new) add_items(**kwargs) def ql_info(room, new): for line in sage.buffer: if line[:-1] == room.name: line.output += ansi.grey(' (%s) (%s)' % (room.area, room.id)) if new: line.output += ansi.grey(' [new]') sage.defer_to_prompt(ql_info, room, new)
def ql(alias): sage.defer_to_prompt(write_players)