//Determine what type of gate this is
IfSpawned
  tmpargument = 1
  IfContentIs
    DoNothing
  Else
    tmpargument = passage
    ClosePassage

//One-way gate
tmpargument = 2
IfContentIs
  IfTimeOut
    tmpargument = 15
    SetTime
    tmpargument = passage + 1
    SetTargetToWhoeverIsInPassage
      IfTargetCanOpenStuff
        tmpargument = passage
        OpenPassage
    Else
      tmpargument = passage
      ClosePassage

//This function makes the door open if its passage is open
KeepAction			//
tmpargument = passage		// Is the passage clear?
IfPassageOpen			//
  tmpargument = 0		  //
  IfStateIs			  // State 0 ( Closed )
    tmpargument = ACTIONMG	    //
    DoAction			    //
      tmpargument = 1		      // Open it
      SetState			      //
      tmpargument = 0		      //
      PlaySound			      //
Else
  tmpargument = 1		  //
  IfStateIs			  // State 1 ( Open )
    tmpargument = ACTIONMJ	    // 71 is the code for MJ
    DoAction			    //
      tmpargument = 0		      // Close it
      SetState			      //
      tmpargument = 1		      // Sound effect
      PlaySound			      //

End				// Finished with this character
