 
 



 
		
		 
 The sample game shows a broken radio which can,
-- in theory -- be 'fixed' for one turn by hitting it: The expectation is that the 'fixed radio' should
display as such once, and then revert to being broken.
In practice, the radio never gets fixed: it's as though
the line marked as "PROBLEM HERE" is executed,
ahead of the if statement, or alternatively as
though short_name is being called twice. Deep within the bowels of the standard library, in the routine
"PrefaceByArticle" the PSN routine is called multiple times (PSN, stands
for PrintShortName). On at least one of these occasions, the output of
short_name is captured to a buffer and discarded rather than sent to the
screen. This is when the text "fixed radio" is being printed so it never
sees the light of day. You can verify this by adding a count property
to the object and incrementing it (and printing it) from within
short_name. The first time the name of the radio is printed out, count
is 2. The second time, it is 4. I agree that this is strange behavior, but probably not so much a bug as
a little known fact. You could certainly code around it (by assigning
a counter the value of 2 and decrementing by one inside of short_name
and printing the extra text only if it reaches zero) but I think a more
generalized rule probably says it best: Code that changes the output of
short_name, should not be run from within short_name. Conclusion: this is not thought to be an issue. 
					
			
		
				 
		About Patches   
				
					 
			Issue L61024
					
	
	 
	short_name idiosyncracy 
		Submitted by: Noel Taylor
		    Appeared in: Library 6/10 or before
		    Fixed in: -
	Problem 
   Constant Story "TEST";
  Constant Headline "^An Interactive Test^";
  Include "Parser";
  Include "VerbLib";
  object  whiteroom "~white room~"
    with  description "You are in a white room.",
    has  light;
  object  -> radio
    with  name 'old' 'radio',
          description "It's an old radio.",
          broken true,
          before [; Attack: self.broken = false; "OK."; ],
          short_name [;
              if (self.broken)
                  print "broken radio";
              else {
                  print "fixed radio";
                  self.broken = true; ! PROBLEM HERE
                  }
              rtrue;
          ];
  [ Initialise; location = whiteroom; ];
  Include "Grammar";
Solution (by Jim Fisher) 
 
						
					
					
					
					
  
    Last updated 17 April 2013.
  
  This site is no longer supported; information may be out of date.
  Maintained as a historical archive by the Interactive Fiction Technology Foundation.
  Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
  
    This page was originally managed by Roger Firth.