-
Notifications
You must be signed in to change notification settings - Fork 0
Ch 2. Map Making Rooms Section 2. Coding Excursus 1: Defining Objects
Here’s the overall look of what a typical object in TADS3 will look like:
Notice ‘objectName’ is simply the name of the object. We use this to identify it in throughout our code. The ‘ClassList’ is where our classes go. Classes essentially define the type of object and assign it certain behaviors and properties. Each class has it’s own properties, in this case, the class ‘Room’ has two properties that are called ‘name’ and ‘desc’ (short for description). Notice for the basic type of object, we also end it with a semicolon ‘;’. This is to tell TADS3 that we are ending the object declaration. Of course, objects and classes can contain methods, but we’ll talk about that later.
Of course, with TADS3 flexibility you are given another way to write your code. You can also encase your properties with a pair of open and closed curly brackets, i.e. “{}”. Here’s an example of that.
You can find templates for certain classes in the Adv3Lite Library Reference Manuel. Try to open it in a web browser. When you start the Reference Manuel, this should appear at the top, click on the templates link and it should take you a list titled Templates.
Scroll down until you find the ‘Room’ link, click on it, and it should take you to the Room Template.
Notice that there are question marks. This means that anything that is defined after the ‘roomTitle’, ‘vocab’, and “desc” is an option park of the template.
You may have noticed that there some of the strings (list of text). The ‘roomTitle’ will always be surrounded by single quotes because this type of string is used for displaying brief text, along with the ‘vocab’ declaration as well, whereas the double quotes are reserved for text that text to have a lot of text, more than two or more sentences. Essentially, strings in single quotes will be associated with properties and the double quotes will surround descriptions.