| 1 |
#charset "us-ascii" |
| 2 |
|
| 3 |
/* |
| 4 |
* Copyright (c) 2000, 2006 Michael J. Roberts. All Rights Reserved. |
| 5 |
* |
| 6 |
* TADS 3 Library - module ID's |
| 7 |
* |
| 8 |
* This module defines a framework for "module ID's." The module ID |
| 9 |
* mechanism allows library modules to identify themselves. The module |
| 10 |
* ID framework is modular, in that several libraries can be linked |
| 11 |
* together without any prior knowledge of one another, and the module ID |
| 12 |
* framework will be able to find all of their ID's. |
| 13 |
*/ |
| 14 |
|
| 15 |
/* include the library header */ |
| 16 |
#include "adv3.h" |
| 17 |
|
| 18 |
/* we also require file access */ |
| 19 |
#include <file.h> |
| 20 |
|
| 21 |
|
| 22 |
/* ------------------------------------------------------------------------ */ |
| 23 |
/* |
| 24 |
* Module ID. Each library add-in can define one of these, so that the |
| 25 |
* "credits" command and the like can automatically show the version of |
| 26 |
* each library module included in the finished game, without the game's |
| 27 |
* author having to compile a list of the module versions manually. |
| 28 |
* |
| 29 |
* An easy way to implement a CREDITS command is to define a ModuleID |
| 30 |
* object for the game itself, and override the showCredit() method to |
| 31 |
* display the text of the game's credits. The module object for the |
| 32 |
* game itself should usually have a listingOrder of 1, because the |
| 33 |
* author usually will want the game's information to be displayed first |
| 34 |
* in any listing that shows each included library module (such as the |
| 35 |
* VERSION command's output). |
| 36 |
*/ |
| 37 |
class ModuleID: object |
| 38 |
/* my name */ |
| 39 |
name = '' |
| 40 |
|
| 41 |
/* the "byline" for the module, in plain text and HTML versions */ |
| 42 |
byline = '' |
| 43 |
htmlByline = '' |
| 44 |
|
| 45 |
/* my version number string */ |
| 46 |
version = '' |
| 47 |
|
| 48 |
/* |
| 49 |
* Show my library credit. By default won't show anything. |
| 50 |
* Libraries should generally not override this, because we want to |
| 51 |
* leave it up to the author to determine how the credits are |
| 52 |
* displayed. If a library overrides this, then the author won't be |
| 53 |
* able to control the formatting of the library credit, which is |
| 54 |
* undesirable. |
| 55 |
*/ |
| 56 |
showCredit() { } |
| 57 |
|
| 58 |
/* |
| 59 |
* Show version information. By default, we show our name and |
| 60 |
* version number, then start a new line. The main game's module ID |
| 61 |
* should generally override this to show an appropriate version |
| 62 |
* message for the game, and any library add-ins that want to |
| 63 |
* display their version information can override this to do so. |
| 64 |
*/ |
| 65 |
showVersion() |
| 66 |
{ |
| 67 |
gLibMessages.showVersion(name, version); |
| 68 |
"\n"; |
| 69 |
} |
| 70 |
|
| 71 |
/* |
| 72 |
* Show the "about this game" information. By default, we show |
| 73 |
* nothing here. Typically, only the game's module ID object will |
| 74 |
* override this; in the game's module ID object, this method should |
| 75 |
* display any desired background information about the game that |
| 76 |
* the author wants the player to see on typing the ABOUT command. |
| 77 |
* |
| 78 |
* The ABOUT command conventionally displays information about the |
| 79 |
* game and its author - the kind of thing you'd find in an author's |
| 80 |
* notes section in a book - along with any special instructions to |
| 81 |
* the player, such as notes on unusual command syntax. Information |
| 82 |
* that players will find especially helpful include: |
| 83 |
* |
| 84 |
* - A list of any unusual command phrasings that the game uses. |
| 85 |
* Ideally, you will disclose here every verb that's required to |
| 86 |
* complete the game, beyond the basic set common to most games |
| 87 |
* (LOOK, INVENTORY, NORTH, SOUTH, TAKE, DROP, PUT IN, etc). By |
| 88 |
* disclosing every necessary verb and phrasing, you can be certain |
| 89 |
* to avoid "guess the verb" puzzles. (Note that it's possible to |
| 90 |
* disclose every *required* verb without disclosing every |
| 91 |
* *accepted* verb - some verbs might be so suggestive of a |
| 92 |
* particular puzzle solution that you wouldn't want to disclose |
| 93 |
* them, but as long as you disclose less suggestive alternatives |
| 94 |
* that can be used to solve the same puzzles, you have a valid |
| 95 |
* defense against accusations of using "guess the verb" puzzles.) |
| 96 |
* |
| 97 |
* - A quick overview of the NPC conversation system, if any. |
| 98 |
* Conversation systems have been slowly evolving as authors |
| 99 |
* experiment with different styles, and at least three or four |
| 100 |
* different conventions have emerged. The default that experienced |
| 101 |
* players will expect is the traditional ASK/TELL system, so it's |
| 102 |
* especially important to mention your system if you're using |
| 103 |
* something else. |
| 104 |
* |
| 105 |
* - An indication of the "cruelty" level of the game. In |
| 106 |
* particular, many experienced players find it helpful to know from |
| 107 |
* the outset how careful they have to be about saving positions |
| 108 |
* throughout play, so it's helpful to point out whether or not it's |
| 109 |
* possible for the player character to be killed; whether it's |
| 110 |
* possible to get into situations where the game becomes |
| 111 |
* "unwinnable"; and if the game can become unwinnable, whether or |
| 112 |
* not this will become immediately clear. The kindest games never |
| 113 |
* kill the PC and are always winnable, no matter what actions the |
| 114 |
* player takes; it's never necessary to save these games except to |
| 115 |
* suspend a session for later resumption. The cruelest games kill |
| 116 |
* the PC without warning (although if they offer an UNDO command |
| 117 |
* from a "death" prompt, then even this doesn't constitute true |
| 118 |
* cruelty), and can become unwinnable in ways that aren't readily |
| 119 |
* and immediately apparent to the player, which means that the |
| 120 |
* player could proceed for quite some time (and thus invest |
| 121 |
* substantial effort) after the game is already lost. |
| 122 |
* |
| 123 |
* - A description of any special status line displays or other |
| 124 |
* on-screen information whose meaning might not be immediately |
| 125 |
* apparent. |
| 126 |
*/ |
| 127 |
showAbout() { } |
| 128 |
|
| 129 |
/* |
| 130 |
* My listing order. When we compile a list of modules, we'll sort |
| 131 |
* the modules first by ascending listing order; any modules with |
| 132 |
* the same listing order will be sorted alphabetically by name with |
| 133 |
* respect to the other modules with the same listing order. |
| 134 |
* |
| 135 |
* The value 1 is reserved for the game's own ID object. Note that |
| 136 |
* the TADS 3 library defines a module ID with listing order 50, |
| 137 |
* which is chosen so that the main library credit will appear after |
| 138 |
* the game credits but before any extension credits using the |
| 139 |
* default order value 100 that we define here. Extensions are |
| 140 |
* free, however, to use a number lower than 5 if they wish to |
| 141 |
* appear before the main library credit. |
| 142 |
*/ |
| 143 |
listingOrder = 100 |
| 144 |
|
| 145 |
/* |
| 146 |
* get a list of all of the modules that are part of the game, |
| 147 |
* sorted in listing order |
| 148 |
*/ |
| 149 |
getModuleList() |
| 150 |
{ |
| 151 |
local lst; |
| 152 |
|
| 153 |
/* compile a list of all of the modules */ |
| 154 |
lst = new Vector(10); |
| 155 |
forEachInstance(ModuleID, { obj: lst.append(obj) }); |
| 156 |
lst = lst.toList(); |
| 157 |
|
| 158 |
/* |
| 159 |
* sort the list by listing order (and alphabetically by name |
| 160 |
* where listing orders are the same) |
| 161 |
*/ |
| 162 |
lst = lst.sort(SortAsc, function(a, b) { |
| 163 |
|
| 164 |
/* if the listings order differ, sort by listing order */ |
| 165 |
if (a.listingOrder != b.listingOrder) |
| 166 |
return a.listingOrder - b.listingOrder; |
| 167 |
|
| 168 |
/* the listing orders are the same; sort by name */ |
| 169 |
if (a.name < b.name) |
| 170 |
return -1; |
| 171 |
else if (a.name > b.name) |
| 172 |
return 1; |
| 173 |
else |
| 174 |
return 0; |
| 175 |
}); |
| 176 |
|
| 177 |
/* return the sorted list */ |
| 178 |
return lst; |
| 179 |
} |
| 180 |
; |
| 181 |
|
| 182 |
/* ------------------------------------------------------------------------ */ |
| 183 |
/* |
| 184 |
* A module ID with metadata. During pre-initialization, we'll |
| 185 |
* automatically write out a file with the metadata for each of these |
| 186 |
* objects. This is an abstract base class; a subclass must be created |
| 187 |
* for each specific metadata format. |
| 188 |
*/ |
| 189 |
class MetadataModuleID: ModuleID, PreinitObject |
| 190 |
/* execute pre-initialization */ |
| 191 |
execute() |
| 192 |
{ |
| 193 |
/* write out our metadata */ |
| 194 |
writeMetadataFile(); |
| 195 |
} |
| 196 |
|
| 197 |
/* |
| 198 |
* write our metadata file - this must be overridden by each |
| 199 |
* subclass to carry out the specific steps needed to create and |
| 200 |
* write the metadata file in the appropriate format for the |
| 201 |
* subclass |
| 202 |
*/ |
| 203 |
writeMetadataFile() { } |
| 204 |
; |
| 205 |
|
| 206 |
/* |
| 207 |
* A module ID with GameInfo metadata. The GameInfo metadata format is |
| 208 |
* the standard TADS format for descriptive data about the game. The |
| 209 |
* usual way to use GameInfo metadata is to create a file called |
| 210 |
* "gameinfo.txt" for a game, then embed this file directly in the |
| 211 |
* game's .t3 file using the TADS 3 resource bundler (t3res). Once the |
| 212 |
* gameinfo.txt is embedded in the .t3 file, tools will be able to read |
| 213 |
* the game's descriptive data directly from the .t3 file. For example, |
| 214 |
* HTML TADS on Windows can read the information into its Game Chest, |
| 215 |
* which allows the interpreter to show the full name of the game, the |
| 216 |
* author, and a blurb describing the game, among other things. |
| 217 |
*/ |
| 218 |
class GameInfoModuleID: MetadataModuleID |
| 219 |
/* |
| 220 |
* The IFID - this is a UUID uniquely identifying the game, using the |
| 221 |
* standard UUID format (xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where |
| 222 |
* each 'x' is a hexadecimal digit). You should pick an IFID when |
| 223 |
* you start each game project, and then keep the same IFID |
| 224 |
* throughout the game's entire existence, *including* version |
| 225 |
* updates. Each new version release of the same game - even major |
| 226 |
* new versions - should use the same IFID, so that the versions can |
| 227 |
* all be related to one another as the same game. |
| 228 |
* |
| 229 |
* If the game has multiple IFIDs, list them here, separated by |
| 230 |
* commas. You should NOT *intentionally* create multiple IFIDs for |
| 231 |
* your game; once you've created an IFID, it should be the unique |
| 232 |
* and permanent identifier for the game. In particular, do NOT |
| 233 |
* create a new IFID for a new version: the whole series of releases |
| 234 |
* throughout a game's lifetime should be identified by a single |
| 235 |
* IFID, so that archivists will know that the versions are all |
| 236 |
* incarnations of the same work. |
| 237 |
* |
| 238 |
* The reason that multiple IFIDs are allowed at all is that many |
| 239 |
* older games were not assigned explicit UUID-style IFIDs when |
| 240 |
* released. In such cases, the game has an "implied" IFID based on |
| 241 |
* an MD5 hash of the compiled game file's contents. Every release |
| 242 |
* that doesn't contain an explicit IFID will therefore have a |
| 243 |
* different implied IFID. So, for example, if you've already |
| 244 |
* released versions 1, 2, and 3 of your game, and you didn't assign |
| 245 |
* explicit IFID values to those releases, each version will have a |
| 246 |
* different implied IFID. When you release version 4, you should |
| 247 |
* NOT assign a new UUID-style IFID. Instead, in the IFID string |
| 248 |
* here, list ALL THREE of the implied IFIDs from the past releases. |
| 249 |
* Each of the three IFIDs counts from now on as an IFID for the |
| 250 |
* work, for all versions collectively. (By placing the list of |
| 251 |
* IFIDs in version 4, you prevent version 4 from adding yet another |
| 252 |
* implied IFID of its own: the explicit IFID list supersedes the |
| 253 |
* implied IFID.) See the Babel spec for more information, and for |
| 254 |
* instructions on how to calculate the implied IFID for a TADS game |
| 255 |
* that was released without a UUID-style IFID. |
| 256 |
*/ |
| 257 |
IFID = '' |
| 258 |
|
| 259 |
/* |
| 260 |
* The game's headline. It's become an IF tradition to use a |
| 261 |
* quasi-subtitle of the sort that Infocom used, of the form "An |
| 262 |
* Interactive Mystery." This can be used to define that subtitle. |
| 263 |
*/ |
| 264 |
headline = '' |
| 265 |
|
| 266 |
/* |
| 267 |
* If this game is part of a series, such as a trilogy, these can be |
| 268 |
* used to identify the name of the series and the position in the |
| 269 |
* series. The series name should be something like "The Enchanter |
| 270 |
* Trilogy"; the series number, if provided, should be a simple |
| 271 |
* integer string ('1', '2', etc) giving the position in the series. |
| 272 |
* Note that the series number isn't required even if a series name |
| 273 |
* is specified, since some series are just groups of works without |
| 274 |
* any particular ordering. |
| 275 |
*/ |
| 276 |
seriesName = '' |
| 277 |
seriesNumber = '' |
| 278 |
|
| 279 |
/* |
| 280 |
* The genre of the game. Some games don't fit any particular genre, |
| 281 |
* and some authors just don't like the idea of having to pigeonhole |
| 282 |
* their games, so feel free to leave it out. If there's a good fit |
| 283 |
* to a well-established genre, though, you can specify it here. We |
| 284 |
* recommend you keep this short - one word, maybe two - and use a |
| 285 |
* genre name that's generally recognized as such. You might want to |
| 286 |
* use Baf's Guide as a reference (http://www.wurb.com/if/genre). |
| 287 |
*/ |
| 288 |
genreName = '' |
| 289 |
|
| 290 |
/* |
| 291 |
* The forgiveness level, according to the Zarfian scale propounded |
| 292 |
* by Andrew Plotkin on rec.arts.int-fiction. This must be one of |
| 293 |
* these terms, using the exact capitalization shown: Merciful, |
| 294 |
* Polite, Tough, Nasty, Cruel. |
| 295 |
*/ |
| 296 |
forgivenessLevel = '' |
| 297 |
|
| 298 |
/* |
| 299 |
* The names and email addresses of the authors, in GameInfo format. |
| 300 |
* This list must use the following format: |
| 301 |
* |
| 302 |
* author one <email>; author two <email> <email>; ... |
| 303 |
* |
| 304 |
* In other words, list the first author's name, followed by one or |
| 305 |
* more email addresses, in angle brackets, for the first author. |
| 306 |
* If more than one author is to be listed, add a semicolon, |
| 307 |
* followed by the name of the second author, followed by the second |
| 308 |
* author's email address or addresses, enclosing each in angle |
| 309 |
* brackets. Repeat as needed for additional authors. The list |
| 310 |
* does not need to end with a semicolon; semicolons are merely used |
| 311 |
* to separate entries. |
| 312 |
*/ |
| 313 |
authorEmail = '' |
| 314 |
|
| 315 |
/* |
| 316 |
* The game's web site, if any. If specified, this must be an |
| 317 |
* absolute URL with http protocol - that is, it must be of the form |
| 318 |
* "http://mydomain.com/...". |
| 319 |
*/ |
| 320 |
gameUrl = '' |
| 321 |
|
| 322 |
/* |
| 323 |
* Descriptive text for the game, in plain text format. This is a |
| 324 |
* short description that can be used, for example, in a catalog of |
| 325 |
* games. This should be a couple of sentences or so. |
| 326 |
*/ |
| 327 |
desc = '' |
| 328 |
|
| 329 |
/* |
| 330 |
* Descriptive text for the game, as an HTML fragment. This should |
| 331 |
* have the same information as the 'desc', but this version can use |
| 332 |
* HTML markups (including tags and character entities) to embellish |
| 333 |
* the display of the text. Any HTML markups should be "in-line" |
| 334 |
* body elements only, not "block" or head elements, so that this |
| 335 |
* text can be inserted into a larger HTML document. For example, |
| 336 |
* markups like <i> and <b> are fine, but <p> and <table> should not |
| 337 |
* be used. |
| 338 |
*/ |
| 339 |
htmlDesc = '' |
| 340 |
|
| 341 |
/* |
| 342 |
* The release date. By default, we compute this statically to be |
| 343 |
* today's date. This means this will be set to the date of |
| 344 |
* compilation. If the game wishes to override this, note that the |
| 345 |
* GameInfo format requires this to be of the form YYYY-MM-DD. For |
| 346 |
* example, December 9, 2001 would be '2001-12-09'. |
| 347 |
*/ |
| 348 |
releaseDate = static getGameInfoToday() |
| 349 |
|
| 350 |
/* |
| 351 |
* The date of first publication. This can be just a year in YYYY |
| 352 |
* format, or a full YYYY-MM-DD date. This is the original release |
| 353 |
* date of the original version of the game, which is often of |
| 354 |
* interest to archivists. This should *not* be updated when a new |
| 355 |
* release is made - it's always the date of *original* publication. |
| 356 |
*/ |
| 357 |
firstPublished = '' |
| 358 |
|
| 359 |
/* |
| 360 |
* The language in which this game's text is written. This is the |
| 361 |
* RFC3066 language code for the main language of the work. For |
| 362 |
* example, games written in US English would use 'en-US', while |
| 363 |
* games written in British English would use 'en-GB'. Note that |
| 364 |
* each language-specific library module should use 'modify' to set |
| 365 |
* this to the default for the library. |
| 366 |
*/ |
| 367 |
languageCode = '' |
| 368 |
|
| 369 |
/* |
| 370 |
* The license type for this game. Most text IF games these days |
| 371 |
* are released as freeware, so we use this as the default. The |
| 372 |
* GameInfo metadata format defines several other standard license |
| 373 |
* types, including Public Domain, Shareware, Commercial Demo, |
| 374 |
* Commercial, and Other. Authors should change this if they plan |
| 375 |
* to release under a licensing model other than freeware. |
| 376 |
* |
| 377 |
* Note that the GameInfo metadata format documentation explicitly |
| 378 |
* states that the license type indicated here is advisory only and |
| 379 |
* cannot be considered definitive. This means that this setting |
| 380 |
* does not take away any of the author's rights to set specific |
| 381 |
* license terms. Even so, we recommend that you pick an |
| 382 |
* appropriate value here to avoid any confusion. |
| 383 |
*/ |
| 384 |
licenseType = 'Freeware' |
| 385 |
|
| 386 |
/* |
| 387 |
* The copying rules for this game. Most text games these days are |
| 388 |
* released as freeware with minimal restrictions on copying, so we |
| 389 |
* use a default of "nominal cost only." Other values defined in the |
| 390 |
* GameInfo format include Prohibited, No Restrictions, No-Cost Only, |
| 391 |
* At-Cost Only, and Other. A modifier indicates whether or not the |
| 392 |
* game may be included in compilations (such as those "10,001 great |
| 393 |
* games" CD-R's that people like to sell on auction sites); we |
| 394 |
* indicate that inclusion in compilations is allowed by default. |
| 395 |
* You can change this to "Compilations Prohibited" if you prefer not |
| 396 |
* to allow your game to be distributed in that fashion. |
| 397 |
* |
| 398 |
* Note that the restrictions specified here aren't enforced by any |
| 399 |
* sort of copy-protection or DRM (digital rights management) |
| 400 |
* technology. This information is entirely for the benefit of |
| 401 |
* conscientious users who want to abide by your wishes and thus need |
| 402 |
* to know what your wishes are. |
| 403 |
* |
| 404 |
* The GameInfo bundle is mostly for the benefit of software that can |
| 405 |
* extract the information from the compiled game. So, we recommend |
| 406 |
* that you also put a full notice and explanation of your license |
| 407 |
* restrictions somewhere that users can easily find it, such as in a |
| 408 |
* separate LICENSE.TXT file that you distribute with your game, or |
| 409 |
* in the text of the game itself (displayed by a LICENSE or |
| 410 |
* COPYRIGHT command, for example). |
| 411 |
*/ |
| 412 |
copyingRules = 'Nominal cost only; compilations allowed' |
| 413 |
|
| 414 |
/* |
| 415 |
* The recommended "presentation profile" for the game. 'Default' |
| 416 |
* means that the interpreter's default profile should be used. |
| 417 |
* (Some interpreters let the user select which profile to use as the |
| 418 |
* default, in which case 'Default' means we'll use that profile.) |
| 419 |
*/ |
| 420 |
presentationProfile = 'Default' |
| 421 |
|
| 422 |
/* write our metadata file */ |
| 423 |
writeMetadataFile() |
| 424 |
{ |
| 425 |
local f; |
| 426 |
|
| 427 |
/* |
| 428 |
* open the file - note that the GameInfo.txt resource is |
| 429 |
* required to be encoded in UTF-8, so open the file with the |
| 430 |
* UTF-8 character set |
| 431 |
*/ |
| 432 |
f = File.openTextFile(gameInfoFilename, FileAccessWrite, 'utf-8'); |
| 433 |
|
| 434 |
/* scan our list of metadata keys and write each one */ |
| 435 |
for (local i = 1, local len = metadataKeys.length() ; |
| 436 |
i + 1 <= len ; i += 2) |
| 437 |
{ |
| 438 |
local key; |
| 439 |
local prop; |
| 440 |
local val; |
| 441 |
|
| 442 |
/* get the key name and value property for this entry */ |
| 443 |
key = metadataKeys[i]; |
| 444 |
prop = metadataKeys[i+1]; |
| 445 |
val = self.(prop); |
| 446 |
|
| 447 |
/* turn any '\ ' characters into ' ' characters */ |
| 448 |
val = val.findReplace('\ ', ' ', ReplaceAll); |
| 449 |
|
| 450 |
/* write out this key if there's a value defined for it */ |
| 451 |
if (val != nil && val != '') |
| 452 |
f.writeFile(key + ': ' + val + '\n'); |
| 453 |
} |
| 454 |
|
| 455 |
/* done with the file - close it */ |
| 456 |
f.closeFile(); |
| 457 |
|
| 458 |
/* remember the primary IFID in the globals */ |
| 459 |
libGlobal.IFID = rexReplace([',.*$', '<space>+'], IFID, ''); |
| 460 |
} |
| 461 |
|
| 462 |
/* |
| 463 |
* the GameInfo filename - by default, we write the standard |
| 464 |
* gameinfo.txt file |
| 465 |
*/ |
| 466 |
gameInfoFilename = 'GameInfo.txt' |
| 467 |
|
| 468 |
/* |
| 469 |
* The metadata key mappings. This is a list of key/property pairs. |
| 470 |
* The key in each pair is a string giving a standard GameInfo key |
| 471 |
* name, and the property gives the property (of self) that we |
| 472 |
* evaluate to get the string value for that key. |
| 473 |
*/ |
| 474 |
metadataKeys = |
| 475 |
[ |
| 476 |
'IFID', &IFID, |
| 477 |
'Name', &name, |
| 478 |
'Headline', &headline, |
| 479 |
'Byline', &byline, |
| 480 |
'HtmlByline', &htmlByline, |
| 481 |
'AuthorEmail', &authorEmail, |
| 482 |
'Url', &gameUrl, |
| 483 |
'Desc', &desc, |
| 484 |
'HtmlDesc', &htmlDesc, |
| 485 |
'Version', &version, |
| 486 |
'ReleaseDate', &releaseDate, |
| 487 |
'FirstPublished', &firstPublished, |
| 488 |
'Series', &seriesName, |
| 489 |
'SeriesNumber', &seriesNumber, |
| 490 |
'Genre', &genreName, |
| 491 |
'Forgiveness', &forgivenessLevel, |
| 492 |
'Language', &languageCode, |
| 493 |
'LicenseType', &licenseType, |
| 494 |
'CopyingRules', ©ingRules, |
| 495 |
'PresentationProfile', &presentationProfile |
| 496 |
] |
| 497 |
|
| 498 |
/* |
| 499 |
* get today's date, using the GameInfo standard date format |
| 500 |
* (YYYY-MM-DD) |
| 501 |
*/ |
| 502 |
getGameInfoToday() |
| 503 |
{ |
| 504 |
local dt; |
| 505 |
local mm, dd; |
| 506 |
|
| 507 |
/* get the current date */ |
| 508 |
dt = getTime(GetTimeDateAndTime); |
| 509 |
|
| 510 |
/* get the month, and add a leading zero if it's only one digit */ |
| 511 |
mm = (dt[2] < 10 ? '0' : '') + dt[2]; |
| 512 |
|
| 513 |
/* get the day, and add a leading zero if it's only one digit */ |
| 514 |
dd = (dt[3] < 10 ? '0' : '') + dt[3]; |
| 515 |
|
| 516 |
/* build and return the full YYYY-MM-DD date string */ |
| 517 |
return toString(dt[1]) + '-' + mm + '-' + dd; |
| 518 |
} |
| 519 |
; |
| 520 |
|
| 521 |
|
| 522 |
/* ------------------------------------------------------------------------ */ |
| 523 |
/* |
| 524 |
* Base class for the game's module ID. This merely sets the listing |
| 525 |
* order to 1 so that the game's credit is listed first. Normally, |
| 526 |
* exactly one GameID object, called 'versionInfo', is defined in a game, |
| 527 |
* to provide the game's identifying information. |
| 528 |
* |
| 529 |
* Note that this class is based on GameInfoModuleID, so the library will |
| 530 |
* automatically write out a gameinfo.txt file based on this object's |
| 531 |
* settings. For full GameInfo data, the game should minimally define the |
| 532 |
* following properties (see GameInfoModuleID and ModuleID for details on |
| 533 |
* these properties): |
| 534 |
* |
| 535 |
*. IFID - a random 32-digit hex number to uniquely identify the game; |
| 536 |
*. you can generate one at http://www.tads.org/ifidgen/ifidgen |
| 537 |
*. name - the name of the game |
| 538 |
*. byline - the main author credit: "by so and so" |
| 539 |
*. htmlByline - the main author credit as an HTML fragment |
| 540 |
*. authorEmail - the authors' names and email addresses (in GameInfo format) |
| 541 |
*. desc - a short blurb describing the game, in plain text format |
| 542 |
*. htmlDesc - the descriptive blurb as an HTML ragment |
| 543 |
*. version - the game's version string |
| 544 |
* |
| 545 |
* In addition, you can override the following settings if you don't like |
| 546 |
* the defaults inherited from GameInfoModuleID: |
| 547 |
* |
| 548 |
*. releaseDate - the release date string (YYYY-MM-DD) |
| 549 |
*. licenseType - freeware, shareware, etc. |
| 550 |
*. copyingRules - summary rules on copying |
| 551 |
*. presentationProfile - Multimedia, Plain Text |
| 552 |
*/ |
| 553 |
class GameID: GameInfoModuleID |
| 554 |
/* always list the game's credits before any library credits */ |
| 555 |
listingOrder = 1 |
| 556 |
|
| 557 |
/* |
| 558 |
* Show the game's credits. By default, we'll just show our name and |
| 559 |
* by-line. |
| 560 |
* |
| 561 |
* Typically, authors will want to override this to display the full |
| 562 |
* credits for the game. Most authors like to show the author or |
| 563 |
* authors, along with notes of thanks to important contributors. |
| 564 |
* |
| 565 |
* Note that libraries generally will not show anything automatically |
| 566 |
* in the credits, to allow the author full control over the |
| 567 |
* formatting of the credits. Authors are encouraged to give credit |
| 568 |
* where it's due for any libraries they use. |
| 569 |
*/ |
| 570 |
showCredit() |
| 571 |
{ |
| 572 |
/* by default, just show the game's name and by-line */ |
| 573 |
gLibMessages.showCredit(name, htmlByline); |
| 574 |
} |
| 575 |
|
| 576 |
/* |
| 577 |
* show a blank line after the game's version information, to make |
| 578 |
* it stand apart from the list of library and VM version numbers |
| 579 |
*/ |
| 580 |
showVersion() |
| 581 |
{ |
| 582 |
inherited(); |
| 583 |
"\b"; |
| 584 |
} |
| 585 |
; |
| 586 |
|
| 587 |
/* ------------------------------------------------------------------------ */ |
| 588 |
/* |
| 589 |
* The main TADS 3 library ID. |
| 590 |
*/ |
| 591 |
moduleAdv3: ModuleID |
| 592 |
name = 'TADS 3 Library' |
| 593 |
byline = 'by Michael J.\ Roberts' |
| 594 |
htmlByline = 'by <a href="mailto:[email protected]">' |
| 595 |
+ 'Michael J.\ Roberts</a>' |
| 596 |
version = '3.1.3' |
| 597 |
|
| 598 |
/* |
| 599 |
* We use a listing order of 50 so that, if all of the other credits |
| 600 |
* use the defaults, we appear after the game's own credits |
| 601 |
* (conventionally at listing order 1) and before any extension |
| 602 |
* credits (which inherit the default order 100), but so that |
| 603 |
* there's room for extensions that want to appear before us, or |
| 604 |
* after us but before any default-ordered extensions. |
| 605 |
*/ |
| 606 |
listingOrder = 50 |
| 607 |
; |
| 608 |
|
| 609 |
|
| 610 |
/* ------------------------------------------------------------------------ */ |
| 611 |
/* |
| 612 |
* An ID module not for the library but for the T3 VM itself. This |
| 613 |
* doesn't display any credit information, but displays version number |
| 614 |
* information for the VM so that the "version" command shows what |
| 615 |
* version of the interpreter is in use. |
| 616 |
*/ |
| 617 |
ModuleID |
| 618 |
showVersion() |
| 619 |
{ |
| 620 |
local vsn = t3GetVMVsn(); |
| 621 |
|
| 622 |
/* |
| 623 |
* show the version information - note that we must decompose |
| 624 |
* the version number into the standard 3-part dotted string |
| 625 |
*/ |
| 626 |
gLibMessages.showVersion('T3 VM (' + t3GetVMID() + ')', |
| 627 |
'' + (vsn >> 16) + '.' |
| 628 |
+ ((vsn >> 8) & 0xFF) + '.' |
| 629 |
+ (vsn & 0xFF)); |
| 630 |
"\n"; |
| 631 |
} |
| 632 |
|
| 633 |
/* |
| 634 |
* Use a very high listing order so that we're the last thing shown. |
| 635 |
*/ |
| 636 |
listingOrder = 10000 |
| 637 |
; |
| 638 |
|