Inform - Resources - Examples

Back to List

Inventory
Complete

Backward
Forward

Plain
Coloured
Gaudy

This code
in plain text

Browsing Toyshop.inf

Blackboard (lines 798-862)

798  ! >BB  A blackboard which can be written on or wiped clear.
799  ! ----------------------------------------------------------------------------
800   
801  Object -> -> chalk "stick of chalk"
802    with name "stick" "of" "chalk";
803   
804  Array boardtext string 64;
805   
806  Object -> blackboard "blackboard"
807    with name "board" "blackboard" "black",
808         describe
809         [;  <<Examine self>>; ],
810         before
811         [ i f;
812             Examine:
813                 for (i=1:i<=boardtext->0:i++)
814                     if (boardtext->i~=' ' or 0) f=1;
815                 if (f==0)
816                 {   print "^The office blackboard is wiped clean.^";
817                     if (self hasnt general)
818                     {   give self general;
819                         "^[To write on it, try   > write ~message...~]";
820                     }
821                     rtrue;
822                 }
823                 print "^The office blackboard bears the message:^    ";
824                 for (i=1:i<=boardtext->0:i++)
825                 {   f=boardtext->i;
826                     if (f~=0) print (char) f;
827                 }
828                 new_line; rtrue;
829             Rub: for (i=1:i<=boardtext->0:i++) boardtext->i = ' ';
830                    "You wipe the blackboard clean.";
831         ],
832    has  static;
833   
834  Global from_char; Global to_char;
835  [ QuotedText i j f;
836     i = WordAddress(wn++); i=i-buffer;
837     if (buffer->i=='"')
838     {   for (j=i+1:j<=(buffer->1)+1:j++)
839             if (buffer->j=='"') f=j;
840         if (f==0) return -1;
841         from_char = i+1; to_char=f-1;
842         if (from_char>to_char) return -1;
843         while (buffer+f > WordAddress(wn)) wn++; wn++;
844         return 1;
845     }
846     return -1;
847  ];
848   
849  [ WriteSub i j;
850     if (chalk notin player) "You're holding nothing to write with.";
851     if (blackboard notin location) "The blackboard is elsewhere.";
852     for (i=from_char,j=1:i<=to_char && j<boardtext->0:i++,j++)
853         boardtext->j = buffer->i;
854     for (:j<boardtext->0:j++) boardtext->j=0;
855     Achieved(5);
856     <<Examine blackboard>>;
857  ];
858   
859  ! ----------------------------------------------------------------------------
860  !   End of object definitions.
861  ! ----------------------------------------------------------------------------
862  !


Last updated 23 June 2004. 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 Graham Nelson (graham@gnelson.demon.co.uk) assisted by C Knight.