How to handle complex / sub-objects?

How would you handle complex / sub-objects? I mean, something like a NPC having a face or other body parts. The player could then use a command like "Shave John's face" or "shoot Jake in chest". Or maybe like a puzzle box with multiple disks and knobs.
(This is a QuestJS question but I imagine the answer may be similar to that in Quest5.)


  1. create object john
  2. go to verbs tab of john, add shave verb, at assignment column, switch to require another object
  3. add face object inside the assignment column, then add in script
msg ("clean shaven<br/>")
  1. create object face, drag it and put it inside of john
  2. at john, go to features tab, tick container, go to container tab, choose container, tick hide children until looked at
  3. at john, go to object tab, delete open and close from display and inventory verbs
  4. play test the game, if you type in "shave john", it is not possible
    if you type in "shave john face", it is not possible
    if you type in "look john", "shave john", it would list out a possible list of options, when you click on 1. face,
    you will finally shave john's face, receiving a confirmation message "clean shaven"
  5. additionally, if you feel like hiding the sub-objects afterwards, go to john, setup tab, at look at, switch to run script and add this
SetTimeout (9) {
  MakeObjectInvisible (face)
}

Quick demo/ Sample code

To paste the code
Startup your quest gamebook/textadventure, on the right side of the big play button, you can see a code view button
Copy my code to replace the code in the text box, click code view button again.
Viola, it is done, press play button to test out the game and modify the code to your preference.

<!--Saved by Quest 5.8.6836.13983-->
<asl version="580">
  <include ref="English.aslx" />
  <include ref="Core.aslx" />
  <game name="test15">
    <gameid>cb2655e4-6bfc-4dd5-be83-b7cab36b49af</gameid>
    <version>1.0</version>
    <firstpublished>2024</firstpublished>
  </game>
  <object name="room">
    <inherit name="editor_room" />
    <isroom />
    <object name="player">
      <inherit name="editor_object" />
      <inherit name="editor_player" />
    </object>
    <object name="john">
      <inherit name="editor_object" />
      <inherit name="container_open" />
      <shave type="scriptdictionary">
        <item key="face"><![CDATA[
          msg ("clean shaven<br/>")
        ]]></item>
      </shave>
      <feature_container />
      <hidechildren />
      <displayverbs type="stringlist">
        <value>Look at</value>
        <value>Take</value>
      </displayverbs>
      <inventoryverbs type="stringlist">
        <value>Look at</value>
        <value>Use</value>
        <value>Drop</value>
      </inventoryverbs>
      <onopen type="script">
      </onopen>
      <look type="script">
        SetTimeout (9) {
          MakeObjectInvisible (face)
        }
      </look>
      <object name="face">
        <inherit name="editor_object" />
      </object>
    </object>
  </object>
  <verb>
    <property>shave</property>
    <pattern>shave</pattern>
    <defaultexpression>"You can't shave " + object.article + "."</defaultexpression>
  </verb>
</asl>

Very interesting, thank you.
Unfortunately I've decided to refactor the code to use QuestJS' respond() function, and potentially remove these sub-objects entirely, replacing them with dictionaries. For posterity, I will add that QuestJS has built in support for component objects with the COMPONENT() object type.


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

Support

Forums