//The different states:
//0: Closed
//1: Open
//------------------------------------------------------------------
//Just in case
IfSpawned
  tmpargument = passage
  ClosePassage
  tmpargument = ACTIONMJ
  DoAction			//Closed animation

//------------------------------------------------------------------
// Someone cast an unlock spell
IfOrdered
  tmpx = selforder
  tmpy = 491  			// The unique code for an unlock order
  IfXIsEqualToY
    tmpargument = 0		    // Is it closed?
    IfStateIs
      tmpargument = 2
      SendMessageNear		//Tell it dint work
      PlaySound			//Funky sound

//------------------------------------------------------------------
//Open if both keys are used
IfTimeOut
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
  tmpargument = [KEYB]
  IfTargetHasItemID
    CostTargetItemID
      tmpargument = passage
      OpenPassage			//Yep
      tmpargument = 0
      SendMessageNear
  tmpargument = 5
  SetTime

//------------------------------------------------------------------
// Handle the animation and sound
KeepAction
tmpargument = passage	// Is the passage clear?
IfPassageOpen
  tmpargument = 0
  IfStateIs				//Don't loop
    tmpargument = ACTIONMG
    DoAction
      tmpargument = 1
      SetState
      tmpargument = 0
      PlayFullSound

//------------------------------------------------------------------
End				// Finished with this character
//------------------------------------------------------------------
