~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to include/dirs.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
!----------------------------------------------------------------------------
2
 
! Dirs.h
3
 
!----------------------------------------------------------------------------
4
 
! Author:  Nicholas Daley <daleys@ihug.co.nz>
5
 
! Version: 2.1
6
 
! Purpose: Provides a 'dirs' meta-verb that tells you which directions you
7
 
!          can go in.
8
 
!
9
 
! It just checks if a value was given for the <dir>_to properties, so if one
10
 
! stored a string or a routine, then it will be included.  If cant_go moves
11
 
! the player, then this is _not_ included.
12
 
! Location objects can provide an allow_directions property which may tell
13
 
! dirs.h:a)(return false)Print if the location provides the corresponding
14
 
!                        *_to property
15
 
!        b)("    " true)The direction has already been printed
16
 
!        c)("    " 2)Ignore this direction - don't print it
17
 
!        d)("    " default)Definitely print this direction
18
 
!----------------------------------------------------------------------------
19
 
!Revision History:1.0=Original version (doesn't work with library 6/3 or
20
 
!                     later)
21
 
!                 2.0=Works with libraries before and after library 6/3
22
 
!                     Added the 'allow_directions' property
23
 
!                 2.1=can use verbs 'exits' or 'list exits' too.
24
 
!----------------------------------------------------------------------------
25
 
#ifndef DirectionName; #ifndef LanguageDirection;
26
 
  Message fatalerror "dirs.h requires DirectionName() or \
27
 
                      LanguageDirection() to be declared (this should be \
28
 
                      done by the library)";
29
 
#endif; #endif;
30
 
 
31
 
Property allow_directions;
32
 
 
33
 
[ DirsSub i flag flag2 j loc;
34
 
  print "You can go:^";
35
 
  if(location==thedark) loc=real_location;
36
 
  else loc=location;
37
 
  j=0;
38
 
  objectloop(i in Compass) {
39
 
   if(loc provides allow_directions)
40
 
    switch(loc.allow_directions(i))
41
 
     {
42
 
      false:flag=false;flag2=false;  !Print if the corresponding *_to property
43
 
                                     !is provided
44
 
      true:j++;flag2=true;           !The direction has already been printed.
45
 
      2:flag2=true;                  !Ignore this direction (do not print it)
46
 
      default:flag=true;             !Definitely print this direction
47
 
     };
48
 
 
49
 
   if(loc provides (i.door_dir) && metaclass(loc.(i.door_dir))~=nothing ||
50
 
      flag==true && flag2==false)
51
 
    {
52
 
      print " ";
53
 
#ifdef DirectionName;
54
 
      DirectionName(i.door_dir);
55
 
#ifnot;
56
 
 #ifdef LanguageDirection;     
57
 
      LanguageDirection(i.door_dir);
58
 
 #endif;
59
 
#endif;
60
 
     new_line;
61
 
     j++;
62
 
    }
63
 
  }
64
 
 if(j==0) " nowhere";
65
 
];
66
 
 
67
 
 Verb meta "dirs" "directions" * -> Dirs;
68
 
 Verb meta "list" * "exits" -> Dirs;
69
 
 Verb meta "exits" * -> Dirs;