Skip to content

Template: CONSTRUCTION

ThePix edited this page Aug 24, 2021 · 5 revisions

A construction is an item that the player can make during the game. Generally, a construction has a list of items that player needs to make it, and these should be passed to the template as an array of item names.

createItem("paper_funnel", TAKEABLE(), CONSTRUCTION(["sheet_of_paper"]), {
  examine:'A funnel, made of paper.',
})

Here is another example. There is no list of components, but a custom "buildPrecheck" checks the player is on the beach instead. The item can also be destroyed. The "buildAtLocation" attribute is set to true so the item will be placed at the location, not in the player inventory. there is also a custom "msgConstruction".

createItem("sandcastle", CONSTRUCTION(), {
  synonyms:['sand castle'],
  buildAtLocation:true,
  examine:'The sandcastle looks pretty good.',
  msgConstruction:"You build sandcastle.",
  buildPrecheck:function(options) {
    if (this.loc) return falsemsg(lang.construction_already, options)
    if (options.loc !== 'beach') return falsemsg("There is no sand to build a sandcastle.")
    return true
  },
  smash:function(options) {
    msg("You kick the sandcastle, again and again, until no trace is left.")
    delete this.loc
    return true
  },
})

Notes

The system uses the existence of the item's "loc" attribute to decide if the item has been created. That may have implications if you later delete the attribute.

By default the components used to build the item will get destroyed (their "loc" attribute will be deleted). To prevent that, set "destroyComponentsOnBuild" to false.

QuestJS also has a transform function; I would suggest using that when it is still the same thing. Animating a corpse should use transform, because it is still a corpse; more here.

Tutorial

QuestJS Basics

The Text Processor

Commands

Templates for Items

See also:

Handing NPCs

The User Experience (UI)

The main screen

The Side Panes

Multi-media (sounds, images, maps, etc.)

Dialogue boxes

Other Elements

Role-playing Games

Web Basics

How-to

Time

Items

Locations

Exits

Meta

Meta: About The Whole Game

Releasing Your Game

Reference

Clone this wiki locally