//------------------------------------------------------------------------------------

//Manage all switches that are pulled
IfOrdered
  tmpx = selforder
  tmpy = 1
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument + 1
    SetContent
  tmpx = selforder
  tmpy = 2
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument - 1
    SetContent
  tmpy = 3
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument + 3
    SetContent
  tmpy = 4
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument - 3
    SetContent
  tmpy = 5
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument +5
    SetContent
  tmpy = 6
  IfXIsEqualToY
    GetContent
    tmpargument = tmpargument -5
    SetContent

//Randomize puzzle answer
IfSpawned
  tmpargument = rand % 5 + 7
  SetState

//Check if the puzzle is solved
GetContent
tmpx = tmpargument
tmpy = selfstate			//This is the puzzle answer
IfXIsEqualToY
  tmpargument = 0
  SendMessage
  PlayFullSound			//Play jingle
  tmpx = selfx
  tmpy = selfy
  tmpargument = 63			//Create the key
  tmpdistance = 900
  SpawnExactCharacterXYZ
  tmpargument = 20
  tmpdistance = EXPSECRET		//Award some xp
  GiveExperienceToGoodTeam
  GoPoof

//------------------------------------------------------------------------------------
End					// All done
//------------------------------------------------------------------------------------
