def try_get_from(ch, cont, arg): '''tries to get one item from inside another''' if not cont.istype("container"): mud.message(ch, None, cont, None, True, "to_char", "$o is not a container.") elif cont.container_is_closed: mud.message(ch, None, cont, None, True, "to_char", "$o is closed.") else: # find our count and name num, name = utils.get_count(arg) # multi or single? if num == "all": list = utils.find_all_objs(ch, cont.objs, name) for obj in list: do_get(ch, obj, cont) else: # obj = find_obj(ch, cont.objs, num, name) obj = mudobj.find_obj(arg, cont, ch) if obj != None: do_get(ch, obj, cont) else: mud.message( ch, None, cont, None, True, "to_char", "You could not find what you were looking for in $o.")
def list_room_contents(ch, room): # find our list of visible objects and characters vis_objs = utils.find_all_objs(ch, room.objs, "", None, True) vis_chars = utils.find_all_chars(ch, room.chars, "", None, True) # lists of used furnture, and characters using furniture furniture = [] # find our list of used furniture for obj in vis_objs: if len(obj.chars) > 0: furniture.append(obj) # now remove our used furniture and people using it from the visible lists for furn in furniture: vis_objs.remove(furn) for pers in furn.chars: vis_chars.remove(pers) # show our list of visible characters if ch in vis_chars: vis_chars.remove(ch) if len(vis_chars) > 0: utils.show_list(ch, vis_chars, lambda (x): x.rdesc, lambda (x): x.mdesc) # show our list of used furniture for furn in furniture: list_one_furniture(ch, furn) # show our list of visible objects if len(vis_objs) > 0: utils.show_list(ch, vis_objs, lambda (x): x.rdesc, lambda (x): x.mdesc)
def cmd_inventory(ch, cmd, arg): '''Lists all of the items currently carried in your inventory.''' if len(ch.inv) == 0: ch.send("You are not carrying anything.") else: ch.send("You are carrying:") visible = utils.find_all_objs(ch, ch.inv, "", None, True) utils.show_list(ch, visible, lambda(x): x.name, lambda(x): x.mname)
def try_get_from(ch, cont, arg): '''tries to get one item from inside another''' if not cont.istype("container"): mud.message(ch, None, cont, None, True, "to_char", "$o is not a container.") elif cont.container_is_closed: mud.message(ch, None, cont, None, True, "to_char", "$o is closed.") else: # find our count and name num, name = utils.get_count(arg) # multi or single? if num == "all": list = utils.find_all_objs(ch, cont.objs, name) for obj in list: do_get(ch, obj, cont) else: # obj = find_obj(ch, cont.objs, num, name) obj = mudobj.find_obj(arg, cont, ch) if obj != None: do_get(ch, obj, cont) else: mud.message(ch, None, cont, None, True, "to_char", "You could not find what you were looking for in $o.")