Right and wrong answers in Quest

I'd like to set up an adventure where the player has to choose between several different answers to questions in Quest. For example, the player enters a room and need to unlock a door but the puzzle given is based on answering an English question:

What is a noun?:
a. a person, place, thing, or idea
b. an action word

If the player gives the correct answer the door unlocks and the adventure continues. If the player gives the wrong answer, the door remains locked and the player has to try to continue to solve the puzzle. Is there any easy way to do this in Quest?

Thank you for your help.


K.V.

If you have the desktop version of Quest, create a new game, switch to full code view, delete all existing text, and paste this in. From there, you can check out all the code (in code view or the GUI), and you can see if this is how you'd like things to work.

<!--Saved by Quest 5.7.6606.27193-->
<asl version="550">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="Quiz">
    <gameid>b159956c-ec80-4e36-9160-d6bb2c4aa9d7</gameid>
    <version>1.0</version>
    <firstpublished>2018</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <exit alias="north" to="second room">
      <inherit name="northdirection" />
      <runscript />
      <script type="script"><![CDATA[
        if (not door.locked) {
          if (not door.isopen) {
            msg ("(first opening the door)")
            door.isopen = true
          }
          MoveObject (door, this.to)
          MoveObject (game.pov, this.to)
        }
        else {
          msg ("The door is locked. You must answer the following question to unlock it.<br/>")
          Question1
        }
      ]]></script>
    </exit>
    <object name="door">
      <inherit name="editor_object" />
      <inherit name="openable" />
      <inherit name="container_lockable" />
      <feature_container />
      <keycount type="int">0</keycount>
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Open</value>
        <value>Close</value>
      </displayverbs>
      <nokeymessage>You must answer the question correctly to unlock the door.</nokeymessage>
      <autounlock type="boolean">false</autounlock>
      <autoopen type="boolean">false</autoopen>
      <lock type="script">
        msg ("You can't lock it.")
      </lock>
      <unlock type="script"><![CDATA[
        if (this.locked) {
          msg ("You must answer the question correctly to unlock the door.<br/>")
          Question1
        }
        else {
          msg ("It is not locked.")
        }
      ]]></unlock>
      <inventoryverbs type="stringlist">
        <value>Look at</value>
        <value>Open</value>
        <value>Close</value>
      </inventoryverbs>
    </object>
  </object>
  <object name="second room">
    <inherit name="editor_room" />
    <exit alias="south" to="room">
      <inherit name="southdirection" />
      <runscript />
      <script type="script">
        if (not door.locked) {
          if (not door.isopen) {
            msg ("(first opening the door)")
            door.isopen = true
          }
          MoveObject (door, this.to)
          MoveObject (game.pov, this.to)
        }
        else {
          msg ("The door is locked.")
        }
      </script>
    </exit>
  </object>
  <function name="Question1"><![CDATA[
    ShowMenu ("What is a noun?", Split ("a person, place, thing, or idea;an action word"), false) {
      if (result = "a person, place, thing, or idea") {
        msg ("Correct!<br/><br/>The door is now unlocked!")
        door.locked = false
      }
      else {
        msg ("Incorrect!")
        Question1
      }
    }
  ]]></function>
</asl>

It would be less complicated to lock an exit instead of including a door.

There are numerous ways to handle doors. In this example, I'm just moving the door to the adjacent room each time the player "goes through it". I have scripts set up on the exits to check the status of the door before deciding whether the player is moved or the question is displayed.

If you are planning on doing this in numerous rooms, I would advise leaving doors out of it and locking the actual exits. (If you'd like to do it that way, and you'd like advice, just let us know!)


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums