General notes - ThePix/QuestJS GitHub Wiki
This is a collection of general notes to be aware of while creating your game.
w
object
The In Quest 6 all items and locations belong to the w
object. This means you need to prefix the object's name with w.
when you want to refer to it specifically - but not if you have a reference to it.
In this example, the ball is an item in the game world. To run its "doStuffWithIt" function, we need to access the ball through the w
object. The variable obj
is set to contain a reference to w.ball
; it is then used without w
.
w.ball.doStuffWithIt()
let obj = w.ball
obj.doOtherStuffWithIt()
You can also access objects with square brackets. This requires a string, which could be the actual name, or a variable containing the name.
w['ball'].doStuffWithIt()
let name = 'ball'
w[name].doStuffWithIt()
game
The game object is where global settings for the game world should be set. It has a turn counter and it also tracks real time.
player
and currentLocation
These are global variables that refer to the current player object and the current location of the player object.
What gets saved
This is about what happens when the user saves her progress though your game, rather than what the author saves.
The way data is saved has some important implications. Full details are here, but the important points to be aware of are:
- Only
game
and objects inw
are saved, no other data will be saved (but the player and current location are part ofw
, so will be saved) - Objects in
w
can only be created at set up, not during play - if you want to generate objects during play, use clone (see here) - Only "simple" attributes are saved, that is numbers, string, Booleans, arrays of numbers, arrays of strings
- Attributes on exits are not saved
- Most attributes that are not saved will get deleted on reload (but not all, for example exits and functions)