DavidGriffith / inform6lib

The Inform6 interactive fiction standard library (moved to https://gitlab.com/DavidGriffith/inform6lib)
Other
22 stars 9 forks source link

Spurious '1' printed after PlayerTo() #19

Closed DavidGriffith closed 8 years ago

DavidGriffith commented 8 years ago

Originally reported in #18 by @scott-martinez . Separate problems -- separate issue reports.

Here's some sample code where, if you go through the window, you end up in your neighbor's back yard but a spurious "1" is printed after the description of the back yard.

Constant NO_SCORE; Constant Story "Test"; Constant Headline "^A sample.^"; Include "Parser"; Include "VerbLib";

Object kitchen "Kitchen" with description "You are in a kitchen. There is a window here which you should try to go through.", has light;

Object window "window" kitchen with name 'window', description "Framed by celery green curtains, you see nothing special about the window.", Before [; Climb,Enter: print_ret "You squeeze yourself into the window and fall out the other side.^", PlayerTo(backyard); ], has scenery container openable;

Object backyard "Back Yard" with description "You are in your neighbor's back yard. It is barely cloudy and already hot this morning. The healthy, dark green grass is well manicured. A high wooden fence encompasses the area, painted a burnt umber. The back door is to the east. Your kitchen window is to the south.", before [; Go: if (noun == s_obj) { print "Climbing over the fence you squeeze back through your kitchen window.^"; } ], s_to kitchen, has light;

[ Initialise;

Location = Kitchen;

];

Include "Grammar";

DavidGriffith commented 8 years ago

http://inform7.com/mantis/view.php?id=1803

DavidGriffith commented 8 years ago

It turns out that this is not a bug in the Library or Compiler, but in the test code itself. The code for the window is wrong. It should look this this instead:

Object -> window "window"
    with name 'window',
    description "Framed by celery green curtains, you see nothing special about the window.",
    Before [;
    Climb,Enter:
        print "You squeeze yourself into the window and fall out the other side.^",
        PlayerTo(backyard);
        rtrue;
    ],
    has scenery container openable;

Specific problems:

  1. The window needs to be a child of the kitchen.
  2. You had 'window "window" kitchen' in the object declaration. The "kitchen" part confused the Compiler.
  3. print_ret used improperly and terminated with a comma. That's the biggie that caused the spurious '1' to print. Use "print" instead, then do "rtrue" after the PlayerTo() call.

@scott-martinez, I suspect you were very tired when you wrote that. I've done similar things myself.