Getobj

     getobj - syntax: getobj(key,[room|char|obj],[options]) 

Prog Types: Mob, Object, Room

Getobj is used to find an item in a room, on a specific character or inside another item. The value returned is either nil or an OBJ type variable that can be accessed and manipulated with other Lua functions.

Getobj does not require an actor, which means there are no visiblity checks. It is safe to use from object and room progs.

The first argument should be an object key - getobj intentionally does not work with keywords as builders have no way to predict what keywords will be added to future items. Accessing objects by keyword is unreliable.

The second argument is either a ROOM, a CH or another OBJ type variable. If a room is given, the item is searched for in that room.

If a character is given, the item is searched for on that character and can be restricted to worn or carried only. If an obj is given, the contents of that object are searched.

The options available for the third argument only apply when searching a character, and are:

   LP_CARRIEDONLY Only search carried inventory. 
   LP_WORNONLY Only search worn inventory. 

Some examples:

   --- If there is an instance of aylor-123 in the room, the player 
   --- may proceed north (pressure pads?)
   --- Exit trigger for north.
   local tobj = getobj("aylor-123",room,0)
   if tobj ~= nil then
      transfer(ch,"roomkey-1")
   end

   --- See if the gem has been placed in the statue in the room.
   --- Assume statue is key test-2 and the gem is test-3

   --- Make sure the statue is still here, just in case
   local statue = getobj("test-2",room,0)
   if statue ~= nil then
      --- Is the gem inside it?
      local gem = getobj("test-3",statue,0)
      if gem ~- nil then
         --- The gem is here ... do something.
      end
   end