misc.tfile | source file |
Classes Summary | Objects Summary | Functions Summary Details |
adv3Lite Library - miscellaneous definitions
This module contains miscellaneous definitions that don't have a natural grouping with any larger modules, and which aren't complex enough to justify modules of their own.
ArgumentMismatchError
FinishOption
FinishType
GameMainDef
LCS
LibraryError
Script
SingletonIterator
adv3LibInit
adv3LibPreinit
emumTabInitializer
finishOptionAmusing
finishOptionCredits
finishOptionFullScore
finishOptionQuit
finishOptionRestart
finishOptionRestore
finishOptionScore
finishOptionUndo
firstPersonObj
ftDeath
ftFailure
ftGameOver
ftVictory
libGlobal
libObjectInitializer
restoreOptionRestoreAnother
restoreOptionStartOver
unknownDest_
varDest_
cls
failedRestoreOptions
findMatchingTopic
findPlayerChar
finishGame
finishGameMsg
getPlayerChar
isEmptyStr
isListSubset
isValidIdentifierName
makeMentioned
matchCase
nilToList
objOfKind
overrides
partitionList
processOptions
setPlayer
tryInt
tryNum
valToList
cls ( ) | misc.t[420] |
First, we flush the transcript to ensure that no left-over reports that were displayed before we cleared the screen will show up on the new screen. Second, we call the low-level clearScreen() function to actually clear the display window. Finally, we re-display any <ABOUTBOX> tag, to ensure that the about-box will still be around; this is necessary because any existing <ABOUTBOX> tag is lost after the screen is cleared.
failedRestoreOptions ( ) | misc.t[1077] |
findMatchingTopic (voc, cls, =, Topic) | misc.t[1652] |
findPlayerChar ( ) | misc.t[2633] |
finishGame (extra) | misc.t[1066] |
finishGameMsg (msg, extra) | misc.t[1008] |
We'll show a message defined by 'msg', using a standard format. The format depends on the language, but in English, it's usually the message surrounded by asterisks: "*** You have won! ***". 'msg' can be:
- nil, in which case we display nothing
- a string, which we'll display as the message
- a FinishType object, from which we'll get the message
After showing the message (if any), we'll prompt the user with options for how to proceed. We'll always show the QUIT, RESTART, and RESTORE options; other options can be offered by listing one or more FinishOption objects in the 'extra' parameter, which is given as a list of FinishOption objects. The library defines a few non-default finish options, such as finishOptionUndo and finishOptionCredits; in addition, the game can subclass FinishOption to create its own custom options, as desired.
getPlayerChar ( ) | misc.t[2612] |
isEmptyStr (str) | misc.t[1861] |
isListSubset (a, b) | misc.t[1625] |
isValidIdentifierName (str) | misc.t[2683] |
makeMentioned (obj) | misc.t[1592] |
matchCase (newTok, oldTok) | misc.t[2340] |
We recognize four patterns:
- If the original string has at least one capital letter and no minuscules, we convert the new string to all caps. For example, matchCase('ALPHA-1', 'omicron-7') yields 'OMICRON-7'.
- If the original string has at least one lower-case letter and no capitals, we convert the new string to all lower case. E.g., matchCase('alpha-1', 'OMICRON-7') yields 'omicron-7'.
- If the original string starts with a capital letter, and has at least one lower-case letter and no other capitals, we capitalize the first letter of the new string and lower-case everything else. E.g., matchCase('Alpha-1', 'OMICRON-7') yields 'Omicron-7'.
- Otherwise, we match the case pattern of the input string letter for letter: for each upper-case letter in the original, we capitalize the letter at the corresponding character index in the new string, and likewise with lower-case letters in the original. We leave other characters unchanged. E.g., matchCase('AlPhA-1', 'omicron-7') yields 'OmIcRon-7'.
nilToList (val) | misc.t[1558] |
objOfKind (obj, cls) | misc.t[2608] |
overrides (obj, base, prop) | misc.t[436] |
partitionList (lst, fn) | misc.t[1613] |
The return value is a list with two elements. The first element is a list giving the elements of the original list for which 'fn' returns true, the second element is a list giving the elements for which 'fn' returns nil.
(Contributed by Tommy Nordgren.)
processOptions (lst) | misc.t[1088] |
setPlayer (actor, person, =, 2) | misc.t[1668] |
tryInt (val) | misc.t[1450] |
tryNum (val) | misc.t[1503] |
valToList (val) | misc.t[1568] |