Ignore:
Timestamp:
12/08/09 08:20:30 (10 years ago)
Author:
b0rland_parpg
Message:

Ticket #229: patch by b0rland
Added findItem function which currently allows searching by name and kind inside inventory and container

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/objects/base.py

    r436 r439  
    268268                return self.items[i] 
    269269        return None 
     270 
     271    def findItem(self, **kwargs): 
     272        """Find an item in container by various attributes. All parameters are optional. 
     273           @type name: String 
     274           @param name: Unique or non-unique object name. If the name is non-unique, first matching object is returned 
     275           @type kind: String 
     276           @param kind: One of the possible object kinds like "openable" or "weapon" 
     277           @return: The item matching criteria or None if none was found 
     278        """ 
     279        for i in self.items : 
     280            if "name" in kwargs and self.items[i].name != kwargs["name"]: 
     281                continue 
     282            if "kind" in kwargs and not self.items[i].trueAttr(kwargs["kind"]): 
     283                continue 
     284            return self.items[i] 
     285        return None 
    270286         
    271287class Living (object): 
Note: See TracChangeset for help on using the changeset viewer.