Tutorial 3 ‐ Items - ThePix/QuestJS GitHub Wiki
... Continued from rooms and exits.
Let us create a simple item. You can put this anywhere in data.js or even in code.js, but I recommend putting items directly after the code for location where they start. it makes things easier to find later.
createItem("coin", TAKEABLE(), {
loc:"lounge",
examine: "A gold coin.",
})
We have given it a name, "coin", then given it some default values from TAKEABLE, which allows the player to pick it, then, in our own dictionary, customised it, specifically giving it a location and description. This is about as basic as it gets!
Here are another two items:
createItem("glass_cabinet", CONTAINER(true), {
loc:"lounge",
transparent:true,
examine:"A cabinet with a glass front",
})
createItem("ornate_doll", TAKEABLE(), {
loc:"glass_cabinet",
examine:"A fancy doll, eighteenth century.",
})
The values in a dictionary or array can be arranged on one line or across multiple - whatever is easiest to see (but a string needs to be on a single line). You do not need a comma after the last name-value pair, but it is good to get in the habit of including it, as there will be times you add an extra value and forget it.
Note that the name cannot include spaces, but if you use underscores instead, Quest 6 will automatically give a suitable alias (eg, "glass cabinet"). Names can only include the standard 26 letters (upper or lower case), digits or underscores. If there are any other characters required, set the alias yourself.
The doll's location is the name of the cabinet, not the alias.
These boots use WEARABLE (TAKEABLE is implicit in WEARABLE, so is not required):
createItem("boots", WEARABLE(), {
loc:"lounge",
pronouns:lang.pronouns.plural,
examine:"Some old boots.",
})
They also have the "pronouns" attribute set to the special value lang.pronouns.plural
so Quest will refer to them in the plural.
Here is an NPC item:
createItem("Lara", NPC(true), {
loc:"lounge",
examine:"A normal-sized rabbit.",
})
Note that NPC should be sent true
for a female NPC, false
for male; this will set up the pronouns correctly - but you could override that and set your own value if desired (as with the boots, you could do pronouns:lang.pronouns.plural
for example). As the name starts with a capital letter Quest will take this as a proper noun, so Lara never gets "a" or "the" before her name.
Continues in templates.