- §1. Identification
- §2. Global Variables
- §3. Compass
- §4. Score and Rankings Table
- §5. Other odds and ends
Constant WORLDMODELKIT = 1; Constant USE_SCORING = WorldModelKit`SCORING_CFGV;
§2. Global Variables. These are not the only global variables defined in the template layer: those needed locally only by single sections (and not used in definitions of phrases in the Standard Rules, or referred to by Inform directly) are defined within those sections — they can be regarded as unimportant implementation details, subject to change at whim. The variables here, on the other hand, are more important to understand.
- (1) The first three variables to be defined are special in that they are significant to very early-style Z-machine interpreters, where they are used to produce the status line display (hence sline1 and sline2).
- (2) The say__* are used for the finite state machine used in printing text, which keeps track of automatic paragraph breaking and the like. For details see the "Printing.i6t" section.
- (3) standard_interpreter is used only for the Z-machine VM, and is always 0 for Glulx. For Z, a non-zero value here is the version number of the {\it Z-Machine Standards Document} which the interpreter claims to support, in the form (upper byte).(lower). undo_flag, similarly, behaves slightly differently on the two platforms according to whether they support multiple consecutive UNDOs. UNDO basically works by taking memory snapshots of the whole VM ("saving UNDO") to revert to at a later point ("performing UNDO"), so it is expensive on memory, and traditional VMs can only store a single memory snapshot — making two UNDOs in a row, going back two steps, impossible. Given this, undo_flag has three possible states: 0 means UNDO is not available at all, 1 means it is not available now because there is no further saved state to go back to from here, and 2 means it is available.
- (4) deadflag in normally 0, or false, meaning play continues; 1 means the game ended in death; 2 for ended in victory; higher numbers represent exotic endings. (As from May 2010, the use of 2 for victory is deprecated, and a separate flag, story_complete, records whether the story is "complete" in the sense that we don't expect the player to replay.) deadflag switching state normally triggers an end to rulebook processing, so is the single most important global variable to the running of a story file.
- (5) At present, time_rate is not made use of in I7: if positive, it is the number of minutes which pass each turn; if negative, the number of turns which pass each minute. This is quite a neat way to approximate a wide range of time steps with an integer such that fractions are exact and we can approximate any duration to a fair accuracy (the worst case being \(3/4\) minute, where we have to choose between 1 minute or \(1/2\) minute).
- (6) Note that notify_mode is irrelevant if the use option "Use no scoring" is in force: it isn't looked at, and can't be changed, and shouldn't have an effect anyway since score will never be altered.
- (7) player is a variable, not a constant, since the focus of play can change. SACK_OBJECT is likewise an unexpected variable: in the I6 library, there could only be one player's holdall, a single rucksack-like possession which had to be the value of the constant SACK_OBJECT. Here we define SACK_OBJECT as a global variable instead, the value of which is the player's holdall currently in use. visibility_ceiling is the highest object in the tree visible from the player's point of view: usually the room, but sometimes nothing (in darkness), and sometimes a closed non-transparent container.
- (8) See "OrderOfPlay.i6t" for the meaning of action variables.
- (9) This is a slate of global variables used by the parser to give some context to the general parsing routines (GPRs) which it calls; in the I6 design, any object can provide its own GPR, in the form of a parse_name property. GPRs are in effect parser plug-ins, and I7 makes extensive use of them.
- (10) Similarly, variables for the parser to give context to another sort of plug-in routine: a scope filter. I7 uses these too.
- (11) The move_* variables are specific to the ##Going action.
- (12) These variables hold current settings for listing objects and, more elaborately, performing room descriptions.
- (13) The current colour scheme is stored in variables in order that it can be saved in the save game state, and changed correctly on an UNDO: if it were a transient state inside the VM interpreter's screen model, then a RESTORE or UNDO will upset what the original author may have intended the appearance of text in particular scenes to be. (Cf. Adam Cadre's I6 patch L61007.)
- (14) These pixel dimensions are used both for the Glulx and v6 Z-machines, but not for the more commonly used versions 5 or 8, whose screen model is based on character cells.
(1) Global location = 0; does not = I7 "location": see below Global sline1; Global sline2; (2) Global undo_flag; (4) Global story_complete = 0; Global resurrect_please = false; (5) Global not_yet_in_play = true; set false when first command received Global turns = 1; = I7 "turn count" Global the_time = NULL; = I7 "time of day" Global time_rate = 1; Constant NUMBER_SCENES_CREATED = ICOUNT_SCENE; Constant SCENE_ARRAY_SIZE = (NUMBER_SCENES_CREATED+2); Array scene_started --> SCENE_ARRAY_SIZE; Array scene_ended --> SCENE_ARRAY_SIZE; Array scene_status --> SCENE_ARRAY_SIZE; Array scene_endings --> SCENE_ARRAY_SIZE; Array scene_latest_ending --> SCENE_ARRAY_SIZE; (6) Global score; = I7 "score" Global last_score; = I7 "last notified score" Global notify_mode = 1; score notification on or off Global left_hand_status_line = T_SL_Location; = I7 "left hand status line" Global right_hand_status_line = T_SL_Score_Moves; = I7 "right hand status line" (7) Global real_location; = I7 "location" Global visibility_ceiling; highest object in tree visible to player Global visibility_levels; distance in tree to that Global SACK_OBJECT; current player's holdall item in use (8) Global act_requester; Global actor; = I7 "person asked" = I7 "person reaching" Global actors_location; like real_location, but for the actor Global actor_location; = I7 "actor-location" Global meta; action is out of world Global inp1; Global inp2; Array multiple_object --> WorldModelKit`MULTI_OBJ_LIST_SIZE_CFGV; multiple-object list (I6 table array) Global toomany_flag; multiple-object list overflowed Global multiflag; multiple-object being processed Global multiple_object_item; item currently being processed in multiple-object list Global noun; = I7 "noun" Global second; = I7 "second noun" Global keep_silent; true if current action is being tried silently Global trace_actions = 0; Global untouchable_object; Global untouchable_silence; Global touch_persona; Global special_word; dictionary address of first word in "[text]" token Global consult_from = 1; word number of start of "[text]" token Global consult_words; number of words in "[text]" token Global parsed_number; value from any token not an object Global special_number1; first value, if token not an object Global special_number2; second value, if token not an object Array parser_results --> 16; for parser to write its results in Global parser_trace = 0; normally 0, but 1 to 5 traces parser workings Global pronoun_word; records which pronoun ("it", "them", ...) caused an error Global pronoun_obj; and what object it was thought to refer to Global players_command = 100; = I7 "player's command" Global matched_text; = I7 "matched text" Global understand_as_mistake_number; which form of "Understand... as a mistake" Global particular_possession; = I7 "particular possession" (9) Global parser_action; written by the parser for the benefit of GPRs Global parser_one; Global parser_two; Global parameters; number of I7 tokens parsed on the current line Global action_reversed; (parameters would be reversed in order) Global wn; word number within "parse" buffer (from 1) Global num_words; number of words in buffer Global verb_word; dictionary address of command verb Global verb_wordnum; word number of command verb (10) Global scope_reason = PARSING_REASON; current reason for searching scope Global scope_token; for "scope=Routine" grammar tokens Global scope_error; Global scope_stage; 1, 2 then 3 Global advance_warning; what a later-named thing will be Global reason_code = NULL; for the I6 veneer Global ats_flag = 0; for AddToScope routines Global ats_hls; (11) Global move_pushing; Global move_from; Global move_to; Global move_by; Global move_through; (12) Global lookmode = WorldModelKit`ROOM_DESC_DETAIL_CFGV; 1 = BRIEF, 2 = VERBOSE, 3 = SUPERBRIEF Global c_style; current list-writer style Global c_depth; current recursion depth Global c_iterator; current iteration function Global lt_value = EMPTY_TEXT_VALUE; common value of list_together Global listing_together; object number of one member of a group being listed together Global listing_size; size of such a group Global c_margin; current level of indentation printed by WriteListFrom() Global inventory_stage = 1; 1 or 2 according to the context in which list_together uses Global debug_scenes = 0;
§3. Compass. I6 identified compass directions as being children of the pseudo-object Compass, so we define it. (Note that Compass is not a valid I7 object, and is used for no other purpose.) Because of the traditional structure of language definitions, this needs to come first.
Object Compass "compass" has concealed;
§4. Score and Rankings Table. The following command tells Inform to compile constant definitions for INITIAL_MAX_SCORE and/or RANKING_TABLE, in cases where there are scores and rankings. If there's no ranking table, RANKING_TABLE is left undefined, so that we can #ifdef this possibility later.
Global MAX_SCORE = INITIAL_MAX_SCORE;
[ ParserError error_type; if (error_type) PrintSingleParagraph(error_type); rfalse; ]; [ UnknownVerb v; if (WorldModelKit`NO_VERB_VERB_EXISTS) { verb_wordnum = 0; return 'no.verb'; } rfalse; ]; [ PrintVerb v; if (WorldModelKit`NO_VERB_VERB_EXISTS) { if (v == 'no.verb') { print "do something to"; rtrue; } } rfalse; ];