Advertisement
logicmoo

Guncho Mockup

Mar 12th, 2016
3,051
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Version 2/080713 of Guncho Mockup (for Glulx only) by Guncho Cabal begins here.
  2.  
  3. "This extension simulates Guncho for offline development."
  4.  
  5. Use authorial modesty.
  6. Use full-length room descriptions.
  7. Use dynamic memory allocation of at least 16384.
  8. Use MAX_STATIC_DATA of 500000.
  9.  
  10. Part 1 - Player characters
  11.  
  12. Chapter 1 - The PC kind
  13.  
  14. A PC is a kind of person. A PC is usually proper-named. The PC kind translates into I6 as "i7_pc_kind".
  15.  
  16. A PC can be reserved or unreserved. A PC is usually unreserved.
  17.  
  18. A PC has indexed text called the mud-name. Rule for printing the name of a PC (called whoever) (this is the PC name printing rule): say mud-name of whoever. Understand the mud-name property as describing a PC.
  19.  
  20. The description of a PC is "[possibly customized description of the item described]".
  21.  
  22. After examining a PC (this is the list PC possessions after examining rule):
  23.     if the noun is wearing something, say "[The noun] is wearing [a list of things worn by the noun.";
  24.     if the noun is carrying something, say "[The noun] is carrying [a list of things carried by the noun]."
  25.  
  26. To say possibly customized description of (victim - PC):
  27.     let custom desc be player attribute "description" of the victim;
  28.     if custom desc is "" begin;
  29.         issue library message examining action number 2 for the victim;
  30.     otherwise;
  31.         say custom desc;
  32.     end if.
  33.  
  34. A PC has a number called the mud-id. The mud-id property translates into I6 as "i7_mud_id". The mud-id of a PC is usually 0.
  35.  
  36. Mud-identification relates a number (called ID) to a PC (called whomever) when ID is the mud-id of whomever. The verb to identify (it identifies, they identify, it identified, it is identified) implies the mud-identification relation.
  37.  
  38. Mud-naming relates indexed text (called the name) to a PC (called whomever) when the name is the mud-name of whomever. The verb to name (it names, they name, it named, it is named) implies the mud-naming relation.
  39.  
  40. The PC-corral is a container. The PC-corral object translates into I6 as "i7_pc_corral". 25 PCs are in the PC-corral.
  41.  
  42. Definition: a PC is connected if it is not in the PC-corral.
  43. Definition: a PC is disconnected if it is in the PC-corral.
  44.  
  45. To transfer consciousness from (source - a PC) to (target - PC):
  46.     now the mud-name of target is the mud-name of source;
  47.     now the mud-name of source is "";
  48.     now the mud-id of target is the mud-id of source;
  49.     now the mud-id of source is 0.
  50.  
  51. Section 1 - Multiplayer pronoun support
  52.  
  53. Include (- with pronouns 0 0 0 0, -) when defining a PC.
  54.  
  55. Include (-
  56. [ ResetPronouns victim  p;
  57.     p = victim.&pronouns;
  58.     if (~~p) rfalse;
  59.     p-->0 = 0; p-->1 = 0; p-->2 = 0; p-->3 = 0;
  60. ];
  61.  
  62. [ SavePronouns victim  p;
  63.     p = victim.&pronouns;
  64.     p-->0 = PronounValue('him');
  65.     p-->1 = PronounValue('her');
  66.     p-->2 = PronounValue('it');
  67.     p-->3 = PronounValue('them');
  68. ];
  69.  
  70. [ LoadPronouns victim  p;
  71.     p = victim.&pronouns;
  72.     SetPronoun('him', p-->0);
  73.     SetPronoun('her', p-->1);
  74.     SetPronoun('it', p-->2);
  75.     SetPronoun('them', p-->3);
  76. ];
  77. -).
  78.  
  79. Chapter 2 - Special input handling
  80.  
  81. When play begins (this is the hide command prompt rule):
  82.     do nothing. [mockup]
  83.  
  84. After reading a command (this is the handle directed input rule):
  85.     do nothing. [mockup]
  86.  
  87. After reading a command (this is the handle special commands rule):
  88.     do nothing. [mockup]
  89.  
  90. Special command handling is a rulebook.
  91.  
  92. The last special command handling rule (this is the unknown special command rule):
  93.     do nothing. [mockup]
  94.  
  95. Chapter 3 - Special output handling
  96.  
  97. [BUGFIX: 5J39 contains a bug where passing indexed text from one phrase to another can cause I6 compilation errors when the second phrase has parameters that are runtime type checked. The "target" parameters here should be typed PC, but they're objects instead to work around this bug.]
  98.  
  99. To tell (message - indexed text) to (target - an object):
  100.     say "{To [the target]: [message]}[line break]". [mockup]
  101.  
  102. To tell (message - indexed text) to everyone else near (target - an object):
  103.     say "{To everyone else near [the target]: [message]}[line break]". [mockup]
  104.  
  105. To tell (message - indexed text) to everyone who can see (spectacle - an object), except the actor:
  106.     say "{To everyone who can see [the spectacle][if except the actor], except the actor[end if]: [message]}[line break]". [mockup]
  107.  
  108. To announce (message - indexed text):
  109.     say "{To everyone in the realm: [message]}[line break]". [mockup]
  110.  
  111. Chapter 4 - Winning and losing
  112.  
  113. Use competitive scoring translates as (- Constant COMPETITIVE_SCORING; -).
  114.  
  115. Include (-
  116. [ PRINT_OBITUARY_HEADLINE_R;
  117.     print "^^    ";
  118.     VM_Style(ALERT_VMSTY);
  119.     print "***";
  120.     #ifdef COMPETITIVE_SCORING;
  121.     if (deadflag == 1) print " ", (the) player, " has lost ";
  122.     if (deadflag == 2) print " ", (the) player, " has won ";
  123.     #ifnot; ! cooperative scoring
  124.     if (deadflag == 1) print " You have lost ";
  125.     if (deadflag == 2) print " You have won ";
  126.     #endif; ! scoring type
  127.     if (deadflag ~= 0 or 1 or 2)  {
  128.         print " ";
  129.         if (deadflag ofclass Routine) (deadflag)();
  130.         if (deadflag ofclass String) print (string) deadflag;
  131.         print " ";
  132.     }
  133.     print "***";
  134.     VM_Style(NORMAL_VMSTY);
  135.     print "^^"; #Ifndef NO_SCORE; print "^"; #Endif;
  136.     rfalse;
  137. ];
  138. -) instead of "Print Obituary Headline Rule" in "OrderOfPlay.i6t".
  139.  
  140. The ask the final question rule is not listed in the shutdown rulebook.
  141.  
  142. Part 2 - Player commands
  143.  
  144. Chapter 1 - Game engine metacommands
  145.  
  146. Section 1 - Joining
  147.  
  148. A special command handling rule (this is the handle joining rule):
  149.     do nothing. [mockup]
  150.  
  151. [TODO: Rewrite this in I6 so it can treat the digits as characters instead of strings.]
  152. To decide which number is numeric value of (T - indexed text):
  153.     let S be 1;
  154.     let L be the number of characters in T;
  155.     if L is 0, decide on 0;
  156.     let negated be false;
  157.     if character number 1 in T is "-" begin;
  158.         let negated be true;
  159.         let S be 2;
  160.     end if;
  161.     let result be 0;
  162.     repeat with N running from S to L begin;
  163.         let C be character number N in T;
  164.         let D be 0;
  165.         if C is "1" begin; let D be 1; otherwise if C is "2"; let D be 2;
  166.         otherwise if C is "3"; let D be 3; otherwise if C is "4"; let D be 4;
  167.         otherwise if C is "5"; let D be 5; otherwise if C is "6"; let D be 6;
  168.         otherwise if C is "7"; let D be 7; otherwise if C is "8"; let D be 8;
  169.         otherwise if C is "9"; let D be 9; otherwise if C is "0"; let D be 0;
  170.         otherwise; decide on 0; end if;
  171.         let result be (result * 10) + D;
  172.     end repeat;
  173.     if negated is true, let result be 0 - result;
  174.     decide on result.
  175.  
  176. To add a player named (new mud-name - indexed text) with ID (new mud-id - number) at location (new path - indexed text):
  177.     do nothing. [mockup]
  178.  
  179. To reset pronouns for (victim - object): (- ResetPronouns({victim}); -).
  180.  
  181. Player joining is an object-based rulebook. The player joining rulebook has a PC called the current PC.
  182.  
  183. The first player joining rule for a PC (called the newbie):
  184.     now the current PC is the newbie.
  185.  
  186. A first player joining rule (this is the initial PC location rule):
  187.     do nothing. [mockup]
  188.  
  189. A first player joining rule (this is the set PC gender rule):
  190.     do nothing. [mockup]
  191.  
  192. A player joining rule for a PC (called newbie) (this is the announce PC connection rule):
  193.     let waygone be player attribute "waygone" of the current PC;
  194.     let dir be the direction known as waygone;
  195.     let msg be indexed text;
  196.     if dir is a direction, let msg be "[The newbie] appears from [directional opposite of dir].";
  197.     otherwise let msg be "[The newbie] fades into view.";
  198.     tell msg to everyone else near the current PC.
  199.  
  200. To say directional opposite of (dir - a direction):
  201.     if dir is up begin;
  202.         say "below";
  203.     otherwise if dir is down;
  204.         say "above";
  205.     otherwise;
  206.         say the opposite of dir;
  207.     end if.
  208.  
  209. To decide which room is the first room:
  210.     repeat with R running through rooms begin;
  211.         decide on R;
  212.     end repeat;
  213.     decide on nothing.
  214.  
  215. Section 2 - Leaving
  216.  
  217. A special command handling rule (this is the handle leaving rule):
  218.     do nothing. [mockup]
  219.  
  220. To remove the player with ID (parting mud-id - number):
  221.     do nothing. [mockup]
  222.  
  223. Player leaving is an object-based rulebook. The player leaving rulebook has a PC called the current PC.
  224.  
  225. The first player leaving rule for a PC (called the goner):
  226.     now the current PC is the goner.
  227.  
  228. A player leaving rule for a PC (called the goner) (this is the drop possessions when leaving rule):
  229.     if the goner has something begin;
  230.         let msg be indexed text;
  231.         let msg be "You leave behind [the list of things had by the goner] as you exit the realm.";
  232.         tell msg to the goner;
  233.         let msg be "[The goner] drops [a list of things had by the goner].";
  234.         tell msg to everyone else near the goner;
  235.         now everything had by the goner is in the location of the goner;
  236.     end if.
  237.  
  238. A player leaving rule for a PC (called the goner) (this is the announce PC disconnection rule):
  239.     let waygone be player attribute "waygone" of the goner;
  240.     let dir be the direction known as waygone;
  241.     if dir is a direction, tell "[The goner] disappears [motion toward dir]." to everyone else near the goner;
  242.     otherwise tell "[The goner] fades away into nothingness." to everyone else near the goner.
  243.  
  244. To say motion toward (dir - a direction):
  245.     if dir is up begin;
  246.         say "upward";
  247.     otherwise if dir is down;
  248.         say "downward";
  249.     otherwise;
  250.         say "to [the dir]";
  251.     end if.
  252.  
  253. The last player leaving rule (this is the low-level PC cleanup rule):
  254.     do nothing. [mockup]
  255.  
  256. Object-homing relates various things to one thing (called the object-home). The verb to be at home in implies the object-homing relation.
  257.  
  258. When play begins (this is the initial object homes rule):
  259.     repeat with X running through things begin;
  260.         now X is at home in the holder of X;
  261.     end repeat.
  262.  
  263. To send (X - a thing) home:
  264.     tell "[The X] disappears." to everyone who can see X;
  265.     move X to the object-home of X;
  266.     tell "[The X] appears." to everyone who can see X.
  267.  
  268. Section 3 - Polling for info
  269.  
  270. A special command handling rule (this is the handle info requests rule):
  271.     do nothing. [mockup]
  272.  
  273. Chapter 2 - Chat commands
  274.  
  275. A special command handling rule (this is the handle chatting and emoting rule):
  276.     do nothing. [mockup]
  277.  
  278. The text spoken is an indexed text that varies.
  279. The chat direction is an indexed text that varies.
  280.  
  281. Chatting is an action applying to nothing.
  282.  
  283. Carry out chatting (this is the standard chatting rule):
  284.     let N be the number of characters in the chat direction;
  285.     tell "You say[if N is not 0] (to [chat direction])[end if], '[the text spoken]'" to the player;
  286.     tell "[The player] says[if N is not 0] (to [chat direction])[end if], '[the text spoken]'" to everyone else near the player.
  287.  
  288. Emoting is an action applying to nothing.
  289.  
  290. Carry out emoting (this is the standard emoting rule):
  291.     if the text spoken matches the regular expression "^<.,:;!?[apostrophe]>", let space be "";
  292.     otherwise let space be " ";
  293.     let the full emote be indexed text;
  294.     let N be the number of characters in the chat direction;
  295.     let the full emote be "[The player][if N is not 0] (to [chat direction])[end if][space][the text spoken]";
  296.     tell the full emote to the player;
  297.     tell the full emote to everyone else near the player.
  298.  
  299. Answering is speech action. Telling someone about something is speech action. Asking someone about something is speech action.
  300.  
  301. Instead of speech action when the noun is a PC (this is the explain chatting rule), say "As you speak the same language, you might as well speak aloud. (Just a ' mark followed by what you'd like to say will suffice.)"
  302.  
  303. Quietly idling is an action out of world, applying to nothing. Understand "qidle" as quietly idling.
  304.  
  305. Chapter 3 - Modified Inform actions
  306.  
  307. This is the new other people looking rule:
  308.     if the actor is not the player and the actor is not a PC, say "[The actor] looks around."
  309.  
  310. The new other people looking rule is listed instead of the other people looking rule in the report looking rules.
  311.  
  312. This is the new other people examining rule:
  313.     if the actor is not the player and the actor is not a PC, say "[The actor] looks closely at [the noun]."
  314.  
  315. The new other people examining rule is listed instead of the report other people examining rule in the report examining rulebook.
  316.  
  317. Report waiting (this is the new report waiting rule):
  318.     stop the action with library message waiting action number 1 for the player.
  319.  
  320. The standard report waiting rule is not listed in any rulebook.
  321.  
  322. The block thinking rule is not listed in any rulebook.
  323.  
  324. Report thinking (this is the standard report thinking rule):
  325.     say "You contemplate your situation."
  326.  
  327. Report someone thinking (this is the standard report someone thinking rule):
  328.     say "[The actor] pauses for a moment, lost in thought."
  329.  
  330. The block waving hands rule is not listed in any rulebook.
  331.  
  332. Report waving hands (this is the standard report waving hands rule):
  333.     say "You wave."
  334.  
  335. Report someone waving hands (this is the standard report someone waving hands rule):
  336.     say "[The actor] waves."
  337.  
  338. The block smelling rule is not listed in any rulebook.
  339.  
  340. Report smelling (this is the standard report smelling rule):
  341.     say "You smell nothing unexpected."
  342.  
  343. Report someone smelling (this is the standard report someone smelling rule):
  344.     say "[The actor] sniffs[if the noun is the player] you[otherwise if the noun is not the location] [the noun][end if]."
  345.  
  346. The block listening rule is not listed in any rulebook.
  347.  
  348. Report listening (this is the standard report listening rule):
  349.     say "You hear nothing unexpected."
  350.  
  351. Report someone listening (this is the standard report someone listening rule):
  352.     say "[The actor] listens[if the noun is the player] to you[otherwise if the noun is not the location] to [the noun][end if]."
  353.  
  354. The block tasting rule is not listed in any rulebook.
  355.  
  356. Report tasting (this is the standard report tasting rule):
  357.     say "You taste nothing unexpected."
  358.  
  359. Report someone tasting (this is the standard report someone tasting rule):
  360.     say "[The actor] licks [if the noun is the player]you[otherwise][the noun][end if]."
  361.  
  362. The block jumping rule is not listed in any rulebook.
  363.  
  364. Report jumping (this is the standard report jumping rule):
  365.     say "You jump on the spot, fruitlessly."
  366.  
  367. Report someone jumping (this is the standard report someone jumping rule):
  368.     say "[The actor] jumps."
  369.  
  370. The block rubbing rule is not listed in any rulebook.
  371.  
  372. Check an actor rubbing a person (this is the block rubbing people rule):
  373.     if the actor is the player, say "That seems intrusively personal." instead;
  374.     stop the action.
  375.  
  376. Report rubbing (this is the standard report rubbing rule):
  377.     say "You achieve nothing by this."
  378.  
  379. Report someone rubbing (this is the standard report someone rubbing rule):
  380.     say "[The actor] rubs [the noun]." instead.
  381.  
  382. The block singing rule is not listed in any rulebook.
  383.  
  384. Report singing (this is the standard report singing rule):
  385.     say "You sing a beautiful tune."
  386.  
  387. Report someone singing (this is the standard report someone singing rule):
  388.     say "[The actor] assails your ears with an out-of-tune ditty."
  389.  
  390. Check quitting the game (this is the block quitting rule):
  391.     say "To disconnect, just type 'quit' by itself." instead.
  392. Check saving the game (this is the block saving rule):
  393.     say "Saving the game state is not permitted." instead.
  394. Check restoring the game (this is the block restoring rule):
  395.     say "Restoring a saved game is not permitted." instead.
  396. Check restarting the game (this is the block restarting rule):
  397.     say "Restarting the game is not permitted." instead.
  398. Check switching the story transcript on (this is the block transcript on rule):
  399.     say "Transcripting is not permitted." instead.
  400. Check switching the story transcript off (this is the block transcript off rule):
  401.     say "Transcripting is not permitted." instead.
  402. Check preferring abbreviated room descriptions (this is the block superbrief rule):
  403.     say "Changing the room description setting is not permitted." instead.
  404. Check preferring unabbreviated room descriptions (this is the block verbose rule):
  405.     say "Changing the room description setting is not permitted." instead.
  406. Check preferring sometimes abbreviated room descriptions (this is the block brief rule):
  407.     say "Changing the room description setting is not permitted." instead.
  408. Check switching score notification on (this is the block notify on rule):
  409.     say "Changing the score notification setting is not permitted." instead.
  410. Check switching score notification off (this is the block notify off rule):
  411.     say "Changing the score notification setting is not permitted." instead.
  412.  
  413. Understand "undo" as a mistake ("Sorry, undo is not available.").
  414. Understand "oops" as a mistake ("Don't worry about it.").
  415. Understand "oops [text]" as a mistake ("Sorry, typo correction is not available.").
  416.  
  417. Chapter 4 - Player interactions
  418.  
  419. Section 1 - Giving items to other players
  420.  
  421. Generosity relates various things to one PC (called the potential recipient). The verb to be offered to implies the generosity relation.
  422.  
  423. Definition: a thing is offered if it is offered to the person asked.
  424.  
  425. Accepting is an action applying to one thing. Understand "accept [something offered]" as accepting. Understand "accept [something]" as accepting.
  426.  
  427. Check giving something to a PC (this is the translate giving to offering rule): try offering the noun to the second noun instead. The translate giving to offering rule is listed before the block giving rule in the check giving it to rules. The translate giving to offering rule is listed after the can't give to a non-person rule in the check giving it to rules.
  428.  
  429. Offering it to is an action applying to two things.
  430.  
  431. Carry out offering it to:
  432.     now the noun is offered to the second noun.
  433.  
  434. Report offering it to (this is the standard report offering rule):
  435.     say "You offer [the noun] to [the second noun]."
  436.  
  437. Report someone offering (this is the standard report someone offering rule):
  438.     if the second noun is the player, say "[The actor] offers you [a noun]. (To accept it, type 'accept [the noun]'.)";
  439.     otherwise say "[The actor] offers [the noun] to [the second noun]."
  440.  
  441. The accepting action has a person called the person offering (matched as "from").
  442.  
  443. Setting action variables for accepting:
  444.     if the noun is enclosed by a person (called the current holder), now the person offering is the current holder.
  445.  
  446. Check accepting a person (this is the block accepting people rule):
  447.     say "You resolve to accept [if the noun is the player]yourself[otherwise][the noun][end if] as a person, faults and all." instead.
  448.  
  449. Check accepting something (this is the can't accept what's not offered rule):
  450.     if the noun is not offered to the player, say "[The noun] is not being offered to you." instead.
  451.  
  452. Carry out accepting:
  453.     now the player carries the noun;
  454.     now the noun is not offered to anyone.
  455.  
  456. Report accepting something (this is the standard report accepting rule):
  457.     say "You accept [the noun][if the person offering is a person] from [the person offering][end if]."
  458.  
  459. Report someone accepting something (this is the standard report someone accepting rule):
  460.     say "[The actor] accepts [the noun][if the person offering is the player] from you[otherwise if the person offering is a person] from [the person offering][end if]."
  461.  
  462. Every turn (this is the cancel expired offers rule):
  463.     repeat with item running through things that are offered to someone begin;
  464.         if the potential recipient of the item cannot see the item, now the item is not offered to anyone;
  465.     end repeat.
  466.  
  467. Section 2 - Showing items to other players
  468.  
  469. The block showing rule is not listed in any rulebook.
  470.  
  471. Report showing something to someone (this is the standard report showing rule):
  472.     say "You hold up [the noun] for [the second noun] to see."
  473.  
  474. Report someone showing something to someone (this is the standard report someone showing rule):
  475.     say "[The actor] holds up [the noun] for ";
  476.     if the second noun is the player
  477.     begin;
  478.         say "you to see. [run paragraph on]";
  479.         try examining the noun;
  480.     otherwise;
  481.         say "[the second noun] to see.";
  482.     end if.
  483.  
  484. Part 3 - Multi-realm awareness
  485.  
  486. Chapter 1 - Sending the player away
  487.  
  488. To send (victim - a PC) to (destination - text):
  489.     say "{Sending [the victim] to '[destination]'}[line break]". [mockup]
  490.  
  491. Chapter 2 - Entrances
  492.  
  493. A special command handling rule (this is the handle locating rule):
  494.     do nothing. [mockup]
  495.  
  496. A special command handling rule (this is the handle entrance checking rule):
  497.     do nothing. [mockup]
  498.  
  499. Table of Entrances
  500. entrance room   entrance token
  501. a room      "default"
  502.  
  503. When play begins (this is the initialize default entrance rule):
  504.     repeat with R running through rooms begin;
  505.         choose the row with entrance token of "default" in the Table of Entrances;
  506.         change the entrance room entry to R;
  507.         continue the action;
  508.     end repeat.
  509.  
  510. To decide whether (T - indexed text) is a valid entrance token:
  511.     repeat through the Table of Entrances begin;
  512.         if T is the entrance token entry, decide yes;
  513.     end repeat;
  514.     decide no.
  515.  
  516. To decide which room is entrance corresponding to (T - indexed text):
  517.     repeat through the Table of Entrances begin;
  518.         if T is the entrance token entry, decide on the entrance room entry;
  519.     end repeat;
  520.     decide on nothing.
  521.  
  522. To decide which text is entrance token corresponding to (R - room):
  523.     repeat through the Table of Entrances begin;
  524.         if R is the entrance room entry, decide on the entrance token entry;
  525.     end repeat;
  526.     decide on "!".
  527.  
  528. To decide which object is closest entrance to (R - room):
  529.     let the shortest distance be 10000;
  530.     repeat through the Table of Entrances begin;
  531.         let the candidate be the entrance room entry;
  532.         let D be the number of moves from the candidate to R, using doors;
  533.         if D is 0, decide on the candidate;
  534.         if D is not -1 and D is less than the shortest distance begin;
  535.             let the shortest distance be D;
  536.             let the result be the candidate;
  537.         end if;
  538.     end repeat;
  539.     decide on the result.
  540.  
  541. To say entrance path to (obj - something):
  542.     if obj is off-stage begin;
  543.         say "~";
  544.         stop;
  545.     end if;
  546.     let R be the location of obj;
  547.     let E be the closest entrance to R;
  548.     if E is not a room begin;
  549.         say "!";
  550.         stop;
  551.     end if;
  552.     say "=[entrance token corresponding to E]";
  553.     while E is not R begin;
  554.         let thataway be the best route from E to R, using doors;
  555.         say ",[thataway in short form]";
  556.         let E2 be the room-or-door thataway from E;
  557.         if E2 is a door, let E be the other side of E2 from E;
  558.         otherwise let E be E2;
  559.     end while;
  560.     while E is not the holder of obj begin;
  561.         if E holds something (called the next level) which encloses obj begin;
  562.             if the next level is a PC, stop;
  563.             say ",%[next level]";
  564.             let E be the next level;
  565.         otherwise;
  566.             say ",!";
  567.             stop;
  568.         end if;
  569.     end while.
  570.  
  571. To say (D - direction) in short form:
  572.     (- print (address) ({D}.&name)-->0; -).
  573.  
  574. [BUGFIX: the type of "obj" should be a thing, not an object.]
  575. To move (obj - an object) along entrance path (path - indexed text):
  576.     while path is not "" begin;
  577.         if path matches the regular expression "^(<^,>*)(?:,(.*))?$" begin;
  578.             let token be the text matching subexpression 1;
  579.             let path be the text matching subexpression 2;
  580.             if token matches the regular expression "^=(.*)$" begin;
  581.                 [ move to entrance ]
  582.                 let E be the entrance corresponding to the text matching subexpression 1;
  583.                 if E is a room, move obj to E;
  584.                 otherwise stop;
  585.             otherwise if token matches the regular expression "^%(.*)$";
  586.                 [ move into container/supporter ]
  587.                 let C be the thing near obj known as the text matching subexpression 1;
  588.                 if C is a thing, move obj to C;
  589.                 otherwise stop;
  590.             otherwise if token is "!";
  591.                 [ error ]
  592.                 stop;
  593.             otherwise if token is "~";
  594.                 [ off-stage ]
  595.                 remove obj from play;
  596.                 stop;
  597.             otherwise;
  598.                 [ move in the named direction ]
  599.                 let thataway be the direction known as token;
  600.                 if thataway is a direction begin;
  601.                     let the target be the bugfixed room-or-door thataway from the location of obj;
  602.                     if the target is a room, move obj to the target;
  603.                     if the target is a door, move obj to the other side of the target from the location of obj;
  604.                 otherwise;
  605.                     stop;
  606.                 end if;
  607.             end if;
  608.         end if;
  609.     end while.
  610.  
  611. [BUGFIX: this phrase is a shim to avoid the resolver bug, which seems to be necessary even though "room __ from __" doesn't have an indexed text parameter.]
  612. To decide which object is bugfixed room-or-door (dir - an object) from (source - an object):
  613.     let result be the room-or-door dir from source;
  614.     decide on result.
  615.  
  616. [BUGFIX: this phrase is a shim to avoid the resolver bug, which seems to be necessary even though "other side of __ from __" doesn't have an indexed text parameter.]
  617. To decide which object is bugfixed other side of (portal - an object) from (source - an object):
  618.     let result be the other side of the portal from the source;
  619.     decide on result.
  620.  
  621. [BUGFIX: the type of "obj" should be a thing, not an object.]
  622. To decide which object is the thing near (obj - an object) known as (name - indexed text):
  623.     let L be the list of objects called name near obj;
  624.     if the number of entries of L is 0, decide on nothing;
  625.     otherwise decide on entry 1 of L.
  626.  
  627. [BUGFIX: the type of "obj" should be a thing, not an object.]
  628. To decide which object is the direction known as (name - indexed text):
  629.     let L be the list of objects called name near the north;
  630.     if the number of entries of L is 0, decide on nothing;
  631.     otherwise decide on entry 1 of L.
  632.  
  633. Include (- [ GetMatchList pov text list  i t rv pov2;
  634.     if (parsetoken_nesting > 0) {
  635.         ! save match globals
  636.         @push match_from; @push match_length;
  637.         @push number_of_classes;
  638.         for (i=0: i<number_matched: i++) {
  639.             t = match_list-->i; @push t;
  640.             t = match_classes-->i; @push t;
  641.             t = match_scores-->i; @push t;
  642.         }
  643.         @push number_matched;
  644.         @push scope_reason; @push parser_inflection;
  645.      }
  646.  
  647.     parsetoken_nesting++;
  648.     SwitchBufferIn(text);
  649.     match_length = 0; number_matched = 0; match_from = 1; scope_reason = PARSING_REASON; parser_inflection = name;
  650.     SearchScope(ScopeCeiling(pov), pov, NOUN_TOKEN);
  651.     SwitchBufferOut();
  652.     rv = I7ListFromMatchList(list);
  653.     parsetoken_nesting--;
  654.  
  655.     if (parsetoken_nesting > 0) {
  656.         ! restore match globals
  657.         @pull parser_inflection; @pull scope_reason;
  658.         @pull number_matched;
  659.         for (i=0: i<number_matched: i++) {
  660.             @pull t; match_scores-->i = t;
  661.             @pull t; match_classes-->i = t;
  662.             @pull t; match_list-->i = t;
  663.         }
  664.         @pull number_of_classes;
  665.         @pull match_length; @pull match_from;
  666.     }
  667.     return rv;
  668. ];
  669.  
  670. [ SwitchBufferIn text  i;
  671.     for ( i=0: i<INPUT_BUFFER_LEN: i++ )
  672.         buffer2->i = buffer->i;
  673.     SetPlayersCommand(text);
  674.     num_words = WordCount();
  675. ];
  676.  
  677. [ SwitchBufferOut  i;
  678.     for ( i=0: i<INPUT_BUFFER_LEN: i++ )
  679.         buffer->i = buffer2->i;
  680.     VM_Tokenise(buffer, parse);
  681.     num_words = WordCount();
  682.     players_command = 100 + WordCount();
  683. ];
  684.  
  685. [ I7ListFromMatchList list desc obj dsize ex len i;
  686.     if ((list==0) || (BlkType(list) ~= LIST_OF_TY)) return false;
  687.     ex = BlkValueExtent(list);
  688.     len = number_matched;
  689.     if (match_length == 0) len = 0;   ! don't waste time with bad matches
  690.     if (len+LIST_ITEM_BASE > ex) {
  691.         if (BlkValueSetExtent(list, len+LIST_ITEM_BASE) == false)
  692.             return 0;
  693.     }
  694.     BlkValueWrite(list, LIST_ITEM_KOV_F, OBJECT_TY);
  695.     BlkValueWrite(list, LIST_LENGTH_F, len);
  696.     for ( i=0: i<len: i++ )
  697.         BlkValueWrite(list, i+LIST_ITEM_BASE, match_list-->i);
  698.     return list;
  699. ]; -).
  700.  
  701. To decide what list of objects is the list of objects called (name - indexed text) near (pov - object): (- GetMatchList({pov},{-pointer-to:name},{-pointer-to-new:LIST_OF_TY}) -).
  702.  
  703. Chapter 3 - Server registers
  704.  
  705. To decide which number is server register (register name - text):
  706.     decide on 0. [mockup]
  707. To change server register (register name - text) to (new value - number):
  708.     do nothing. [mockup]
  709.  
  710. To decide which indexed text is server text register (register name - text):
  711.     decide on "". [mockup]
  712. To change server text register (register name - text) to (new value - indexed text):
  713.     do nothing. [mockup]
  714.  
  715. To decide which indexed text is realm storage slot (register name - text):
  716.     decide on "". [mockup]
  717. To change realm storage slot (register name - text) to (new value - indexed text):
  718.     do nothing. [mockup]
  719.  
  720. [BUGFIX: "subject" parameter type]
  721. To decide which indexed text is player storage slot (register name - text) of (subject - object):
  722.     decide on "". [mockup]
  723.  
  724. [BUGFIX: "subject" parameter type]
  725. To change player storage slot (register name - text) of (subject - object) to (new value - indexed text):
  726.     do nothing. [mockup]
  727.  
  728. [BUGFIX: "subject" parameter type]
  729. To decide which indexed text is player attribute (attribute name - text) of (subject - object):
  730.     decide on "". [mockup]
  731.  
  732. [BUGFIX: "subject" parameter type]
  733. To change player attribute (attribute name - text) of (subject - object) to (new value - indexed text):
  734.     do nothing. [mockup]
  735.  
  736. Chapter 4 - Real-time events
  737.  
  738. A special command handling rule (this is the handle real-time events rule):
  739.     do nothing. [mockup]
  740.  
  741. Real-time event is a rulebook.
  742.  
  743. To request real-time events every (N - number) seconds:
  744.     say "{Requesting real-time events every [N] seconds}[line break]". [mockup]
  745.  
  746. To stop real-time events:
  747.     say "{Stopping real-time events}[line break]". [mockup]
  748.  
  749. Chapter 5 - Shutdown notification
  750.  
  751. A special command handling rule (this is the handle shutdown notices rule):
  752.     do nothing. [mockup]
  753.  
  754. Realm shutdown is a rulebook.
  755.  
  756. [ rte trigger for mockup ... ]
  757.  
  758. Triggering real-time events is an action applying to nothing. Understand "event" as triggering real-time events.
  759.  
  760. Carry out triggering real-time events:
  761.     say "{Triggering real-time events}[line break]";
  762.     follow the real-time event rules.
  763.  
  764. Part 4 - Library patches
  765.  
  766. Chapter 1 - Standard Rules
  767.  
  768. The investigate multiplayer awareness before action rule is listed instead of the investigate player's awareness before action rule in the specific action-processing rules.
  769. The investigate multiplayer awareness after action and report rule is listed instead of the investigate player's awareness after action rule in the specific action-processing rules.
  770. [The report stage rule is not listed in the specific action-processing rules.]
  771.  
  772. The specific action-processing rulebook has a list of PCs called the observant players.
  773.  
  774. This is the investigate multiplayer awareness before action rule:
  775.     abide by the investigate player's awareness before action rule. [mockup]
  776.  
  777. This is the investigate multiplayer awareness after action and report rule:
  778.     abide by the investigate player's awareness after action rule. [mockup]
  779.  
  780. Chapter 2 - "Parser" segment
  781.  
  782. Include (-
  783.     if (held_back_mode == 1) {
  784.         held_back_mode = 0;
  785.         VM_Tokenise(buffer, parse);
  786.         jump ReParse;
  787.     }
  788.  
  789.   .ReType;
  790.  
  791.     cobj_flag = 0;
  792.     BeginActivity(READING_A_COMMAND_ACT); if (ForActivity(READING_A_COMMAND_ACT)==false) {
  793.         Keyboard(buffer,parse);
  794.         players_command = 100 + WordCount();
  795.         num_words = WordCount();
  796.     } if (EndActivity(READING_A_COMMAND_ACT)) jump ReType;
  797.  
  798.   .ReParse;
  799.  
  800.     parser_inflection = name;
  801.  
  802.     ! Initially assume the command is aimed at the player, and the verb
  803.     ! is the first word
  804.  
  805.     num_words = WordCount();
  806.     wn = 1;
  807.  
  808.     #Ifdef LanguageToInformese;
  809.     LanguageToInformese();
  810.     ! Re-tokenise:
  811.     VM_Tokenise(buffer,parse);
  812.     #Endif; ! LanguageToInformese
  813.  
  814.     num_words = WordCount();
  815.  
  816.     k=0;
  817.     #Ifdef DEBUG;
  818.     if (parser_trace >= 2) {
  819.         print "[ ";
  820.         for (i=0 : i<num_words : i++) {
  821.  
  822.             #Ifdef TARGET_ZCODE;
  823.             j = parse-->(i*2 + 1);
  824.             #Ifnot; ! TARGET_GLULX
  825.             j = parse-->(i*3 + 1);
  826.             #Endif; ! TARGET_
  827.             k = WordAddress(i+1);
  828.             l = WordLength(i+1);
  829.             print "~"; for (m=0 : m<l : m++) print (char) k->m; print "~ ";
  830.  
  831.             if (j == 0) print "?";
  832.             else {
  833.                 #Ifdef TARGET_ZCODE;
  834.                 if (UnsignedCompare(j, HDR_DICTIONARY-->0) >= 0 &&
  835.                     UnsignedCompare(j, HDR_HIGHMEMORY-->0) < 0)
  836.                      print (address) j;
  837.                 else print j;
  838.                 #Ifnot; ! TARGET_GLULX
  839.                 if (j->0 == $60) print (address) j;
  840.                 else print j;
  841.                 #Endif; ! TARGET_
  842.             }
  843.             if (i ~= num_words-1) print " / ";
  844.         }
  845.         print " ]^";
  846.     }
  847.     #Endif; ! DEBUG
  848.     verb_wordnum = 1;
  849.     actor = player;
  850.     actors_location = ScopeCeiling(player);
  851.     usual_grammar_after = 0;
  852.  
  853.   .AlmostReParse;
  854.  
  855.     scope_token = 0;
  856.     action_to_be = NULL;
  857.  
  858.     ! Begin from what we currently think is the verb word
  859.  
  860.   .BeginCommand;
  861.  
  862.     wn = verb_wordnum;
  863.     verb_word = NextWordStopped();
  864.  
  865.     ! If there's no input here, we must have something like "person,".
  866.  
  867.     if (verb_word == -1) {
  868.         best_etype = STUCK_PE;
  869.         jump GiveError;
  870.     }
  871.  
  872.     ! Now try for "again" or "g", which are special cases: don't allow "again" if nothing
  873.     ! has previously been typed; simply copy the previous text across
  874.  
  875.     if (verb_word == AGAIN2__WD or AGAIN3__WD) verb_word = AGAIN1__WD;
  876.     if (verb_word == AGAIN1__WD) {
  877.     print "['again' may only be used on a line by itself. Sorry.]^";
  878.     jump ReType;
  879.     }
  880.  
  881.     ! Save the present input in case of an "again" next time
  882.  
  883.     if (verb_word ~= AGAIN1__WD)
  884.         for (i=0 : i<INPUT_BUFFER_LEN : i++) buffer3->i = buffer->i;
  885.  
  886.     if (usual_grammar_after == 0) {
  887.         j = verb_wordnum;
  888.         i = RunRoutines(actor, grammar);
  889.         #Ifdef DEBUG;
  890.         if (parser_trace >= 2 && actor.grammar ~= 0 or NULL)
  891.             print " [Grammar property returned ", i, "]^";
  892.         #Endif; ! DEBUG
  893.  
  894.         if ((i ~= 0 or 1) && (VM_InvalidDictionaryAddress(i))) {
  895.             usual_grammar_after = verb_wordnum; i=-i;
  896.         }
  897.  
  898.         if (i == 1) {
  899.             results-->0 = action;
  900.             results-->1 = noun;
  901.             results-->2 = second;
  902.             rtrue;
  903.         }
  904.         if (i ~= 0) { verb_word = i; wn--; verb_wordnum--; }
  905.         else { wn = verb_wordnum; verb_word = NextWord(); }
  906.     }
  907.     else usual_grammar_after = 0;
  908. -) instead of "Parser Letter A" in "Parser.i6t".
  909.  
  910. Include (-
  911. [ NounDomain domain1 domain2 context
  912.     first_word i j k l answer_words marker;
  913.     #Ifdef DEBUG;
  914.     if (parser_trace >= 4) {
  915.         print "   [NounDomain called at word ", wn, "^";
  916.         print "   ";
  917.         if (indef_mode) {
  918.             print "seeking indefinite object: ";
  919.             if (indef_type & OTHER_BIT)  print "other ";
  920.             if (indef_type & MY_BIT)     print "my ";
  921.             if (indef_type & THAT_BIT)   print "that ";
  922.             if (indef_type & PLURAL_BIT) print "plural ";
  923.             if (indef_type & LIT_BIT)    print "lit ";
  924.             if (indef_type & UNLIT_BIT)  print "unlit ";
  925.             if (indef_owner ~= 0) print "owner:", (name) indef_owner;
  926.             new_line;
  927.             print "   number wanted: ";
  928.             if (indef_wanted == 100) print "all"; else print indef_wanted;
  929.             new_line;
  930.             print "   most likely GNAs of names: ", indef_cases, "^";
  931.         }
  932.         else print "seeking definite object^";
  933.     }
  934.     #Endif; ! DEBUG
  935.  
  936.     match_length = 0; number_matched = 0; match_from = wn;
  937.  
  938.     SearchScope(domain1, domain2, context);
  939.  
  940.     #Ifdef DEBUG;
  941.     if (parser_trace >= 4) print "   [ND made ", number_matched, " matches]^";
  942.     #Endif; ! DEBUG
  943.  
  944.     wn = match_from+match_length;
  945.  
  946.     ! If nothing worked at all, leave with the word marker skipped past the
  947.     ! first unmatched word...
  948.  
  949.     if (number_matched == 0) { wn++; rfalse; }
  950.  
  951.     ! Suppose that there really were some words being parsed (i.e., we did
  952.     ! not just infer).  If so, and if there was only one match, it must be
  953.     ! right and we return it...
  954.  
  955.     if (match_from <= num_words) {
  956.         if (number_matched == 1) {
  957.             i=match_list-->0;
  958.             return i;
  959.         }
  960.  
  961.         ! ...now suppose that there was more typing to come, i.e. suppose that
  962.         ! the user entered something beyond this noun.  If nothing ought to follow,
  963.         ! then there must be a mistake, (unless what does follow is just a full
  964.         ! stop, and or comma)
  965.  
  966.         if (wn <= num_words) {
  967.             i = NextWord(); wn--;
  968.             if (i ~=  AND1__WD or AND2__WD or AND3__WD or comma_word
  969.                    or THEN1__WD or THEN2__WD or THEN3__WD
  970.                    or BUT1__WD or BUT2__WD or BUT3__WD) {
  971.                 if (lookahead == ENDIT_TOKEN) rfalse;
  972.             }
  973.         }
  974.     }
  975.  
  976.     ! Now look for a good choice, if there's more than one choice...
  977.  
  978.     number_of_classes = 0;
  979.  
  980.     if (number_matched == 1) i = match_list-->0;
  981.     if (number_matched > 1) {
  982.         i = Adjudicate(context);
  983.         if (i == -1) rfalse;
  984.         if (i == 1) rtrue;       !  Adjudicate has made a multiple
  985.                              !  object, and we pass it on
  986.     }
  987.  
  988.     ! If i is non-zero here, one of two things is happening: either
  989.     ! (a) an inference has been successfully made that object i is
  990.     !     the intended one from the user's specification, or
  991.     ! (b) the user finished typing some time ago, but we've decided
  992.     !     on i because it's the only possible choice.
  993.     ! In either case we have to keep the pattern up to date,
  994.     ! note that an inference has been made and return.
  995.     ! (Except, we don't note which of a pile of identical objects.)
  996.  
  997.     if (i ~= 0) {
  998.         if (dont_infer) return i;
  999.         if (inferfrom == 0) inferfrom=pcount;
  1000.         pattern-->pcount = i;
  1001.         return i;
  1002.     }
  1003.  
  1004.     ! If we get here, there was no obvious choice of object to make.  If in
  1005.     ! fact we've already gone past the end of the player's typing (which
  1006.     ! means the match list must contain every object in scope, regardless
  1007.     ! of its name), then it's foolish to give an enormous list to choose
  1008.     ! from - instead we go and ask a more suitable question...
  1009.  
  1010.     if (match_from > num_words) jump Incomplete;
  1011.  
  1012.     ! Now we print up the question, using the equivalence classes as worked
  1013.     ! out by Adjudicate() so as not to repeat ourselves on plural objects...
  1014.  
  1015.     BeginActivity(ASKING_WHICH_DO_YOU_MEAN_ACT);
  1016.     if (ForActivity(ASKING_WHICH_DO_YOU_MEAN_ACT)) jump SkipWhichQuestion;
  1017.  
  1018.     if (context==CREATURE_TOKEN) L__M(##Miscellany, 45);
  1019.     else                         L__M(##Miscellany, 46);
  1020.  
  1021.     j = number_of_classes; marker = 0;
  1022.     for (i=1 : i<=number_of_classes : i++) {
  1023.         while (((match_classes-->marker) ~= i) && ((match_classes-->marker) ~= -i)) marker++;
  1024.         k = match_list-->marker;
  1025.  
  1026.         if (match_classes-->marker > 0) print (the) k; else print (a) k;
  1027.  
  1028.         if (i < j-1)  print (string) COMMA__TX;
  1029.         if (i == j-1) {
  1030.             #Ifdef SERIAL_COMMA;
  1031.             print ",";
  1032.             #Endif; ! SERIAL_COMMA
  1033.             print (string) OR__TX;
  1034.         }
  1035.     }
  1036.     L__M(##Miscellany, 57);
  1037.  
  1038.     .SkipWhichQuestion; EndActivity(ASKING_WHICH_DO_YOU_MEAN_ACT);
  1039.  
  1040.     ! ...and get an answer:
  1041.  
  1042.   .WhichOne;
  1043.     #Ifdef TARGET_ZCODE;
  1044.     for (i=2 : i<INPUT_BUFFER_LEN : i++) buffer2->i = ' ';
  1045.     #Endif; ! TARGET_ZCODE
  1046.     DisambigMode();
  1047.     answer_words=Keyboard(buffer2, parse2);
  1048.  
  1049.     ! Check for another player's command or a system command
  1050.     if (IsOtherCommand(buffer2)) {
  1051.         VM_CopyBuffer(buffer, buffer2);
  1052.         jump RECONSTRUCT_INPUT;
  1053.     }
  1054.  
  1055.     ! Conveniently, parse2-->1 is the first word in both ZCODE and GLULX.
  1056.     first_word = (parse2-->1);
  1057.  
  1058.     ! Take care of "all", because that does something too clever here to do
  1059.     ! later on:
  1060.  
  1061.     if (first_word == ALL1__WD or ALL2__WD or ALL3__WD or ALL4__WD or ALL5__WD) {
  1062.         if (context == MULTI_TOKEN or MULTIHELD_TOKEN or MULTIEXCEPT_TOKEN or MULTIINSIDE_TOKEN) {
  1063.             l = multiple_object-->0;
  1064.             for (i=0 : i<number_matched && l+i<63 : i++) {
  1065.                 k = match_list-->i;
  1066.                 multiple_object-->(i+1+l) = k;
  1067.             }
  1068.             multiple_object-->0 = i+l;
  1069.             rtrue;
  1070.         }
  1071.         L__M(##Miscellany, 47);
  1072.         jump WhichOne;
  1073.     }
  1074.  
  1075.     ! If the first word of the reply can be interpreted as a verb, then
  1076.     ! assume that the player has ignored the question and given a new
  1077.     ! command altogether.
  1078.     ! (This is one time when it's convenient that the directions are
  1079.     ! not themselves verbs - thus, "north" as a reply to "Which, the north
  1080.    ! or south door" is not treated as a fresh command but as an answer.)
  1081.  
  1082.     #Ifdef LanguageIsVerb;
  1083.     if (first_word == 0) {
  1084.         j = wn; first_word = LanguageIsVerb(buffer2, parse2, 1); wn = j;
  1085.     }
  1086.     #Endif; ! LanguageIsVerb
  1087.     if (first_word ~= 0) {
  1088.         j = first_word->#dict_par1;
  1089.         if ((0 ~= j&1) && ~~LanguageVerbMayBeName(first_word)) {
  1090.             VM_CopyBuffer(buffer, buffer2);
  1091.             jump RECONSTRUCT_INPUT;
  1092.         }
  1093.     }
  1094.  
  1095.     ! Now we insert the answer into the original typed command, as
  1096.     ! words additionally describing the same object
  1097.     ! (eg, > take red button
  1098.     !      Which one, ...
  1099.     !      > music
  1100.     ! becomes "take music red button".  The parser will thus have three
  1101.     ! words to work from next time, not two.)
  1102.  
  1103.     #Ifdef TARGET_ZCODE;
  1104.     k = WordAddress(match_from) - buffer; l=buffer2->1+1;
  1105.     for ( j=buffer + buffer->0 - 1 : j>=buffer+k+l : j-- ) j->0 = 0->(j-l);
  1106.     for (i=0 : i<l : i++) buffer->(k+i) = buffer2->(2+i);
  1107.     buffer->(k+l-1) = ' ';
  1108.     buffer->1 = buffer->1 + l;
  1109.     if (buffer->1 >= (buffer->0 - 1)) buffer->1 = buffer->0;
  1110.     #Ifnot; ! TARGET_GLULX
  1111.     k = WordAddress(match_from) - buffer;
  1112.     l = (buffer2-->0) + 1;
  1113.     for ( j=buffer+INPUT_BUFFER_LEN-1 : j>=buffer+k+l : j-- ) j->0 = j->(-l);
  1114.     for (i=0 : i<l : i++) buffer->(k+i) = buffer2->(WORDSIZE+i);
  1115.     buffer->(k+l-1) = ' ';
  1116.     buffer-->0 = buffer-->0 + l;
  1117.     if (buffer-->0 > (INPUT_BUFFER_LEN-WORDSIZE)) buffer-->0 = (INPUT_BUFFER_LEN-WORDSIZE);
  1118.     #Endif; ! TARGET_
  1119.  
  1120.     ! Having reconstructed the input, we warn the parser accordingly
  1121.     ! and get out.
  1122.  
  1123.     .RECONSTRUCT_INPUT;
  1124.  
  1125.     num_words = WordCount();
  1126.     wn = 1;
  1127.     #Ifdef LanguageToInformese;
  1128.     LanguageToInformese();
  1129.     ! Re-tokenise:
  1130.     VM_Tokenise(buffer,parse);
  1131.     #Endif; ! LanguageToInformese
  1132.     num_words = WordCount();
  1133.     players_command = 100 + WordCount();
  1134.     FollowRulebook(Activity_after_rulebooks-->READING_A_COMMAND_ACT, true);
  1135.  
  1136.     return REPARSE_CODE;
  1137.  
  1138.     ! Now we come to the question asked when the input has run out
  1139.     ! and can't easily be guessed (eg, the player typed "take" and there
  1140.     ! were plenty of things which might have been meant).
  1141.  
  1142.   .Incomplete;
  1143.  
  1144.     if (context == CREATURE_TOKEN) L__M(##Miscellany, 48);
  1145.     else                           L__M(##Miscellany, 49);
  1146.  
  1147.     #Ifdef TARGET_ZCODE;
  1148.     for (i=2 : i<INPUT_BUFFER_LEN : i++) buffer2->i=' ';
  1149.     #Endif; ! TARGET_ZCODE
  1150.     DisambigMode();
  1151.     answer_words = Keyboard(buffer2, parse2);
  1152.  
  1153.     ! Check for another player's command or a system command
  1154.     if (IsOtherCommand(buffer2)) {
  1155.         VM_CopyBuffer(buffer, buffer2);
  1156.         jump RECONSTRUCT_INPUT;
  1157.     }
  1158.  
  1159.     first_word=(parse2-->1);
  1160.     #Ifdef LanguageIsVerb;
  1161.     if (first_word==0) {
  1162.         j = wn; first_word=LanguageIsVerb(buffer2, parse2, 1); wn = j;
  1163.     }
  1164.     #Endif; ! LanguageIsVerb
  1165.  
  1166.     ! Once again, if the reply looks like a command, give it to the
  1167.     ! parser to get on with and forget about the question...
  1168.  
  1169.     if (first_word ~= 0) {
  1170.         j = first_word->#dict_par1;
  1171.         if (0 ~= j&1) {
  1172.             VM_CopyBuffer(buffer, buffer2);
  1173.             return REPARSE_CODE;
  1174.         }
  1175.     }
  1176.  
  1177.     ! ...but if we have a genuine answer, then:
  1178.     !
  1179.     ! (1) we must glue in text suitable for anything that's been inferred.
  1180.  
  1181.     if (inferfrom ~= 0) {
  1182.         for (j=inferfrom : j<pcount : j++) {
  1183.             if (pattern-->j == PATTERN_NULL) continue;
  1184.             #Ifdef TARGET_ZCODE;
  1185.             i = 2+buffer->1; (buffer->1)++; buffer->(i++) = ' ';
  1186.             #Ifnot; ! TARGET_GLULX
  1187.             i = WORDSIZE + buffer-->0;
  1188.             (buffer-->0)++; buffer->(i++) = ' ';
  1189.             #Endif; ! TARGET_
  1190.  
  1191.             #Ifdef DEBUG;
  1192.             if (parser_trace >= 5)
  1193.                 print "[Gluing in inference with pattern code ", pattern-->j, "]^";
  1194.             #Endif; ! DEBUG
  1195.  
  1196.             ! Conveniently, parse2-->1 is the first word in both ZCODE and GLULX.
  1197.  
  1198.             parse2-->1 = 0;
  1199.  
  1200.             ! An inferred object.  Best we can do is glue in a pronoun.
  1201.             ! (This is imperfect, but it's very seldom needed anyway.)
  1202.  
  1203.             if (pattern-->j >= 2 && pattern-->j < REPARSE_CODE) {
  1204.                 PronounNotice(pattern-->j);
  1205.                 for (k=1 : k<=LanguagePronouns-->0 : k=k+3)
  1206.                     if (pattern-->j == LanguagePronouns-->(k+2)) {
  1207.                         parse2-->1 = LanguagePronouns-->k;
  1208.                         #Ifdef DEBUG;
  1209.                         if (parser_trace >= 5)
  1210.                             print "[Using pronoun '", (address) parse2-->1, "']^";
  1211.                         #Endif; ! DEBUG
  1212.                         break;
  1213.                     }
  1214.             }
  1215.             else {
  1216.                 ! An inferred preposition.
  1217.                 parse2-->1 = VM_NumberToDictionaryAddress(pattern-->j - REPARSE_CODE);
  1218.                 #Ifdef DEBUG;
  1219.                 if (parser_trace >= 5)
  1220.                     print "[Using preposition '", (address) parse2-->1, "']^";
  1221.                 #Endif; ! DEBUG
  1222.             }
  1223.  
  1224.             ! parse2-->1 now holds the dictionary address of the word to glue in.
  1225.  
  1226.             if (parse2-->1 ~= 0) {
  1227.                 k = buffer + i;
  1228.                 #Ifdef TARGET_ZCODE;
  1229.                 @output_stream 3 k;
  1230.                  print (address) parse2-->1;
  1231.                 @output_stream -3;
  1232.                 k = k-->0;
  1233.                 for (l=i : l<i+k : l++) buffer->l = buffer->(l+2);
  1234.                 i = i + k; buffer->1 = i-2;
  1235.                 #Ifnot; ! TARGET_GLULX
  1236.                 k = Glulx_PrintAnyToArray(buffer+i, INPUT_BUFFER_LEN-i, parse2-->1);
  1237.                 i = i + k; buffer-->0 = i - WORDSIZE;
  1238.                 #Endif; ! TARGET_
  1239.             }
  1240.         }
  1241.     }
  1242.  
  1243.     ! (2) we must glue the newly-typed text onto the end.
  1244.  
  1245.     #Ifdef TARGET_ZCODE;
  1246.     i = 2+buffer->1; (buffer->1)++; buffer->(i++) = ' ';
  1247.     for (j=0 : j<buffer2->1 : i++,j++) {
  1248.         buffer->i = buffer2->(j+2);
  1249.         (buffer->1)++;
  1250.         if (buffer->1 == INPUT_BUFFER_LEN) break;
  1251.     }
  1252.     #Ifnot; ! TARGET_GLULX
  1253.     i = WORDSIZE + buffer-->0;
  1254.     (buffer-->0)++; buffer->(i++) = ' ';
  1255.     for (j=0 : j<buffer2-->0 : i++,j++) {
  1256.         buffer->i = buffer2->(j+WORDSIZE);
  1257.         (buffer-->0)++;
  1258.         if (buffer-->0 == INPUT_BUFFER_LEN) break;
  1259.     }
  1260.     #Endif; ! TARGET_
  1261.  
  1262.     ! (3) we fill up the buffer with spaces, which is unnecessary, but may
  1263.     !     help incorrectly-written interpreters to cope.
  1264.  
  1265.     #Ifdef TARGET_ZCODE;
  1266.     for (: i<INPUT_BUFFER_LEN : i++) buffer->i = ' ';
  1267.     #Endif; ! TARGET_ZCODE
  1268.  
  1269.     return REPARSE_CODE;
  1270.  
  1271. ]; ! end of NounDomain
  1272. -) instead of "Noun Domain" in "Parser.i6t".
  1273.  
  1274. Include (-
  1275. [ DisambigMode;
  1276.     ! mockup: do nothing
  1277. ];
  1278.  
  1279. [ IsOtherCommand buf  i end c;
  1280.     ! mockup: do nothing
  1281.     rfalse;
  1282. ];
  1283. -).
  1284.  
  1285. Chapter 3 - "WorldModel" segment
  1286.  
  1287. Include (-
  1288. [ ChangePlayer obj  pn;
  1289.     if (~~(obj ofclass K8_person)) return RunTimeProblem(RTP_CANTCHANGE, obj);
  1290.     if (~~(OnStage(obj))) return RunTimeProblem(RTP_CANTCHANGEOFFSTAGE, obj);
  1291.     if (obj == player) return;
  1292.  
  1293.     if (player ofclass i7_pc_kind)
  1294.         SavePronouns(player);
  1295.     if (obj ofclass i7_pc_kind)
  1296.         LoadPronouns(obj);
  1297.  
  1298.     give player ~concealed;
  1299.     ! if (player has remove_proper) give player ~proper;
  1300.     if (player == selfobj) {
  1301.         player.saved_short_name = player.short_name; player.short_name = FORMER__TX;
  1302.     }
  1303.     player = obj;
  1304.     if (player == selfobj) {
  1305.         player.short_name = player.saved_short_name;
  1306.     }
  1307.     ! if (player hasnt proper) give player remove_proper; ! when changing out again
  1308.     ! give player concealed proper;
  1309.     give player concealed;
  1310.  
  1311.     location = LocationOf(player); real_location = location;
  1312.     MoveFloatingObjects();
  1313.     SilentlyConsiderLight();
  1314. ];
  1315. -) instead of "Changing the Player" in "WorldModel.i6t".
  1316.  
  1317. Chapter 4 - "Printing" segment
  1318.  
  1319. Include (-
  1320. [ IndefArt obj i;
  1321.     if (obj == 0) { print (string) NOTHING__TX; rtrue; }
  1322.     i = indef_mode; indef_mode = true;
  1323.     if (obj has proper) { indef_mode = NULL; print (PSN__) obj; indef_mode = i; return; }
  1324.     if (obj provides article) {
  1325.         PrintOrRun(obj, article, true); print " ", (PSN__) obj; indef_mode = i;
  1326.         return;
  1327.     }
  1328.     PrefaceByArticle(obj, 2); indef_mode = i;
  1329. ];
  1330.  
  1331. [ CIndefArt obj i;
  1332.     if (obj == 0) { CPrintOrRun(NOTHING__TX, 0); rtrue; }
  1333.     i = indef_mode; indef_mode = true;
  1334.     if (obj has proper) {
  1335.         indef_mode = NULL;
  1336.         caps_mode = true;
  1337.         print (PSN__) obj;
  1338.         indef_mode = i;
  1339.         caps_mode = false;
  1340.         return;
  1341.     }
  1342.     if (obj provides article) {
  1343.         CPrintOrRun(obj, article); print " ", (PSN__) obj; indef_mode = i;
  1344.         return;
  1345.     }
  1346.     PrefaceByArticle(obj, 2, 0, 1); indef_mode = i;
  1347. ];
  1348.  
  1349. [ DefArt obj i;
  1350.     i = indef_mode; indef_mode = false;
  1351.     if ((~~obj ofclass Object) || obj has proper) {
  1352.         indef_mode = NULL; print (PSN__) obj; indef_mode = i;
  1353.         return;
  1354.     }
  1355.     PrefaceByArticle(obj, 1); indef_mode = i;
  1356. ];
  1357.  
  1358. [ CDefArt obj i;
  1359.     i = indef_mode; indef_mode = false;
  1360.     if ((obj ofclass Object) && (obj has proper)) {
  1361.         indef_mode = NULL;
  1362.         caps_mode = true;
  1363.         print (PSN__) obj;
  1364.         indef_mode = i;
  1365.         caps_mode = false;
  1366.         return;
  1367.     }
  1368.     if ((~~obj ofclass Object) || obj has proper) {
  1369.         indef_mode = NULL; print (PSN__) obj; indef_mode = i;
  1370.         return;
  1371.     }
  1372.     PrefaceByArticle(obj, 0); indef_mode = i;
  1373. ];
  1374.  
  1375. [ PrintShortName obj i;
  1376.     i = indef_mode; indef_mode = NULL;
  1377.     PSN__(obj); indef_mode = i;
  1378. ];
  1379. -) instead of "Object Names III" in "Printing.i6t".
  1380.  
  1381. Chapter 7 - "Actions" segment
  1382.  
  1383. Include (-
  1384. [ REQUESTED_ACTIONS_REQUIRE_R;
  1385.     if ((actor ~= player) && (act_requester)) {
  1386.         if (actor ofclass i7_pc_kind) {
  1387.             print "You can't order other players.^";
  1388.             RulebookFails(); rtrue;
  1389.         }
  1390.         @push say__p;
  1391.         say__p = 0;
  1392.         ProcessRulebook(PERSUADE_RB);
  1393.         if (RulebookSucceeded() == false) {
  1394.             if (say__p == FALSE) L__M(##Miscellany, 72, actor);
  1395.             RulebookFails(); rtrue;
  1396.         }
  1397.         @pull say__p;
  1398.     }
  1399.     rfalse;
  1400. ];
  1401. -) instead of "Requested Actions Require Persuasion Rule" in "Actions.i6t".
  1402.  
  1403. Guncho Mockup ends here.
  1404.  
  1405. ---- DOCUMENTATION ----
  1406.  
  1407. N/A
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement