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.)
john
john
, add shave
verb, at assignment column, switch to require another object
face
object inside the assignment column, then add in scriptmsg ("clean shaven<br/>")
face
, drag it and put it inside of johnjohn
, go to features tab, tick container
, go to container tab, choose container
, tick hide children until looked atjohn
, go to object tab, delete open
and close
from display and inventory verbs1. face
,john
, setup tab, at look at
, switch to run script and add thisSetTimeout (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.