//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 key was used
IfTimeOut
  tmpargument = rand & 15 + 10
  SetTime
  tmpargument = passage
  SetTargetToWhoeverIsInPassage
  tmpargument = [KEYB]
  CostTargetItemID
    tmpargument = passage
    OpenPassage			//Yep
    tmpargument = 0
    SendMessageNear
  Else
    tmpargument = 3
    SendMessageNear
    tmpargument = 100
    SetTime
    
//------------------------------------------------------------------
// Handle the animation and sound
KeepAction
tmpargument = passage	// Is the passage clear?
IfPassageOpen
  tmpargument = 0
  IfStateIs				//Don't loop
    tmpargument = ACTIONMG
    DoAction
      SetState
      tmpargument = 1		      //Spooky sounds
      PlayFullSound
      tmpargument = 0
      PlayFullSound

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