Step 11 : (Verifiing the Combination)

Create a new script called "result". First enter these 3 lines :
  loadroom (SecondRoom)
  wait (2,5)
  walkto (self ; 41 ; 26 ; 3)

Now we have to check the 3 numbers that the player has entered. Add this to the script :

  setnum (codecorrect ; 0)

  if_num (code1 ; 7)
    if_num (code2 ; 5)
      if_num (code3 ; 9)
        setnum (codecorrect ; 1)

  if_num (codecorrect ; 1)
    {
    setobj (safe ; 1)
    playsound (opendoor)
    }

  if_num (codecorrect ; 0)
    speech (self ; That was the wrong combination!)

A number called "codecorrect" is declared and set to "0". Only if the three entered numbers were 7, 5 and 9 "codecorrect" will be set to "1".
Depending on "codecorrect" the safe will open or Horst says that the combination was wrong.

The player would be able to use the safe a second time, but we have to prevent that. Open the script of the "safe" object and modify the "on (use)" event :

  on (use)
    if_obj (safe ; 2)
      {
      setfocus (none)
      loadroom (safe)
      }

Now, only when the safe is closed (in this case state "2") the player is able to enter a combination. If the safe is already opened nothing happens.

Next