Public Functions:Game Getter Functions
Game getter functions provide shortcuts to functions scoped to the game object.
-
MyGame.directions()
An array of direction names
This method returns the current room's exit directions in an array. For
example, a returned object might look like this:
[ "out", "north", "down", "up", "south", "east", "west" ]. -
MyGame.exits()
Object
This method returns the current room's exits as an object with key/value
pairs corresponding to the directions of the exits / and the IDs of the
exit objects.
Expand for example
A returned object might look something like this:
To make use of the return you might do something like this function which gets a list of the current room's exits and then prints a statement for each one.{ "out": "standing_room_out", "north": "standing_room_north", "down": "standing_room_down", "up": "standing_room_up", "south": "standing_room_south", "east": "standing_room_east", "west": "standing_room_west" }let exits = MyGame.room().getExits(); Object.keys(exits).forEach(key => { let exit = exits[key]; let asset = MyGame.getAsset(exit); let msg = `You can go ${key} through the ${asset.name}. `; MyGame.print( msg ); }); - MyGame.input() Object Returns the global input object for this turn.
- MyGame.player() Object This method returns the object of the current player asset.
- MyGame.room() Object This method returns the object of the current room asset.