// See if there is a character in the detect passage
IfTimeOut
  tmpargument = 10
  SetTime
  KeepAction


  // Check if the master passage is open...
  GetContent
  IfPassageOpen
    tmpargument = 10000
    SetTime
    tmpargument = passage + 1
    OpenPassage
    // Make the jewel light up
    tmpargument = 0
    IfArmorIs
      tmpargument = 1
      ChangeArmor
  Else
    // Check if the detect passage is blocked
    tmpargument = passage
    SetTargetToWhoeverIsInPassage
      tmpargument = passage + 1
      OpenPassage
      // Make the jewel light up
      tmpargument = 0
      IfArmorIs
        tmpargument = 1
        ChangeArmor
    Else
      tmpargument = passage + 1
      IfPassageOpen
        ClosePassage
        // Make the jewel darken
        tmpargument = 1
        IfArmorIs
          tmpargument = 0
          ChangeArmor


// Handle the animation and sound
tmpargument = passage + 1	// Is the passage clear?
IfPassageOpen			// 
  tmpargument = 0		  //
  IfStateIs			  // State 0 ( Closed )
    tmpargument = ACTIONMG	    //
    DoAction			    //
      tmpargument = 1		      // Open it
      SetState			      //
      tmpargument = 0		      //
      tmpdistance = 11025	      //
      PlaySound			      //
Else
  tmpargument = 1		  //
  IfStateIs			  // State 1 ( Open )
    tmpargument = ACTIONMJ	    //
    DoAction			    //
      tmpargument = 0		      // Close it
      SetState			      //
      tmpargument = 1		      //
      tmpdistance = 11025	      //
      PlaySound			      //
End				// Finished with this character
