Ch. 2 Map Making Rooms Section 1. Your Very First Room - rrsolomon/tads3-Adv3-lite Wiki

2.1 Rooms

2.1.1 Your Very first room!

No game can take place without a room! Here's how to make a quick room

bedroom: Room
    roomTitle: 'Bedroom'
    desc = "You bed lurks in one corner, the clothes a heap from a restless night. "
;

In the code above, we define two properties to our object: 'roomTitle' (this sets the title for the object that we've just declared) and 'desc' (the description of the room). These are properties that we've assigned to this 'Room' object that we called 'bedroom'. The majority of TADS programming is based on defining objects and their properties.

2.1.2 Room Template

The above-mentioned properties are so common that we can use a template. Symbols for shorthand coding are '+' or '@' or '->' to identify parts of the template. The Room template is very straightforward. Here's an example of what our 'bedroom' object will look like formated to this

bedroom: Room
    roomTitle: 'Bedroom'
    desc = "You bed lurks in one corner, the clothes a heap from a restless night. The only way out is to the east. "
;

2.1.3 Direction and Your Second Room

As we mentioned above, there is a way out towards the east in the 'bedroom' object, following the guide, we can make a 'landing' of some sort.

landing: Room 'Landing'
    "The landing runs from west to east; your bedroom lies west. "
;

Notice that we added a "direction" property to our 'landing' object. There are several acceptable directions.

Compass Direction Special Directions Shipboard Directions
North South East West Northwest Northeast Southwest Southeast Up Down In Out Starboard Port Fore Aft

Now that we know mentioned that there is a direction coming out of the bedroom and into the landing, let’s go back to the ‘bedroom’ object and set the ‘east’ direction variable to ‘landing’, so that there is a connection between the two objects.

bedroom: Room
    roomTitle: 'Bedroom'
    desc = "You bed lurks in one corner, the clothes a heap from a restless night. The only way out is to the east. "
    east = landing
;

2.1.4 Excercise 1

Try to recreate your home or workplace for practice on developing your maps! If you're feeling adventurous, you can totally make something that's totally original and creative!

2.1.5 – Source Code

This is what your source code in your TADS3 file should look like as of right now.

#charset "us-ascii"
#include <tads.h>
#include "advlite.h"

versionInfo: GameID
    IFID = 'This will be different for every game you make'
    name = 'test project for test'
    byline = 'by me'
    htmlByline = 'by <a href="mailto:[email protected]">me</a>'
    version = '1'
    authorEmail = 'me <[email protected]>'
    desc = 'a text project'
    htmlDesc = 'a text project'
;

gameMain: GameMainDef
    /* Define the initial player character; this is compulsory */
    initialPlayerChar = me
;

/* The starting location; this can be called anything you like */

bedroom: Room
    roomTitle: 'Bedroom'
    desc = "You bed lurks in one corner, the clothes a heap from a restless night. The only way out is to the east. "
    east = landing
;

landing: Room 'Landing'
    "The landing runs from west to east; your bedroom lies west. "
;

/*
 * The player character object. This doesn't have to be called 'me', but me is a
 * convenient name. If you change it to something else, remember to change
 * gameMain.InitialPlayerChar accordingly.
 */

+ me: Thing 'you'
    isFixed = true
    person = 2 // change to 1 for a first-person game
    contType = Carrier
    location = bedroom
;