Annotation of 43BSD/games/ddl/sample/routines.ddl, revision 1.1

1.1     ! root        1: ROUTINE VisP;
        !             2: VisP =                          { (Visp List Propno) => True IFF an object }
        !             3: (($eq %1 0) : ($rtrn FALSE))   {       is visible on List that has Propno }
        !             4: (($prop %1 %2) :
        !             5:        ($rtrn TRUE))                   { Found one! }
        !             6: (($or ($prop %1 OPEN)
        !             7:       ($prop %1 TRANS)):                { Look inside...}
        !             8:        ( (VisP ($cont %1) %2): ($rtrn TRUE) ))
        !             9: ($rtrn (VisP ($link %1) %2))
        !            10: ;
        !            11: 
        !            12: ROUTINE Reach;                  { (Reach obj loc) => True IFF the obj   }
        !            13: Reach =                         {       IS the loc or can be reached    }
        !            14: (($eq %2 0) : ($rtrn FALSE))    {       by the loc }
        !            15: (($eq %1 %2): ($rtrn TRUE))
        !            16:                        { Still explore inside }
        !            17: (($prop %2 OPEN):
        !            18:        ((Reach %1 ($cont %2)): ($rtrn TRUE))
        !            19: )
        !            20: ($rtrn  (Reach %1 ($link %2)))
        !            21: 
        !            22: ;
        !            23: 
        !            24: ROUTINE See;                  { (See obj loc) => True IFF the obj   }
        !            25: See   =                         {       IS the loc or can be seen       }
        !            26: (@DARKG: ($rtrn FALSE))                { Can't see in a dark room! }
        !            27: (($eq %2 0) : ($rtrn FALSE))
        !            28: (($eq %1 %2): ($rtrn TRUE))
        !            29: (($or  ($prop %2 TRANS)                 { Still explore inside }
        !            30:        ($prop %2 OPEN)):
        !            31:        ((See   %1 ($cont %2)): ($rtrn TRUE))
        !            32: )
        !            33: ($rtrn  (See   %1 ($link %2)))
        !            34: ;
        !            35: 
        !            36: Avail = 
        !            37:        (($eq ($loc %1) .ME) : ($rtrn TRUE))    { shd be closure, really }
        !            38:        (($not %1):($say "The what?\n")($exit 1))
        !            39:        (($not (See %1 ($cont ($loc .ME)))):
        !            40:                ($say "I can't see that item here.\n")
        !            41:                ($exit 1)
        !            42:          )
        !            43:        (($not (Reach %1 ($cont ($loc .ME)))):
        !            44:                ($say "I can't get at that item.\n")
        !            45:                ($exit 1)
        !            46:          )
        !            47:        (($and ($prop .ME SHRNK)
        !            48:               ($not ($prop %1 SHRNK))  ):
        !            49:                       (($ne ($loc %1) .ME):
        !            50:                                ($say
        !            51: "Right now, ")(($sdesc %1))($say " is too big for you to deal with.\n")
        !            52:                                ($exit 1)
        !            53:                        )
        !            54:          )
        !            55:        ($rtrn TRUE)
        !            56: ;
        !            57: 
        !            58: ROUTINE LitP;
        !            59: LitP =                          { (LitP Room) => True IFF Room is lit }
        !            60: (($prop %1 LIGHT) : ($rtrn TRUE))
        !            61: (($or (VisP ($cont %1) LIGHT)
        !            62:       (VisP ($cont %1) FLAME)): ($rtrn TRUE))
        !            63: 
        !            64: (($or (VisP ($cont .ME) LIGHT)                  { Check .ME 'cause invisibl }
        !            65:       (VisP ($cont .ME) FLAME)): ($rtrn TRUE))
        !            66: ($rtrn FALSE)
        !            67: ;
        !            68: 
        !            69: ROUTINE Blank;
        !            70: Blank =                         { Blank n => Type n blanks }
        !            71: (($gt %1 0):
        !            72:        ($say "  ")
        !            73:        (Blank ($minus %1 1)));
        !            74: 
        !            75: ROUTINE Llook; ROUTINE Slook;
        !            76: Llook =                         { (Llook Level Object) describes Object }
        !            77: (($eq %2 0) : ($exit 0))
        !            78: (($eq %1 0) :                   { Level 0 == This is a room.  Check lighting }
        !            79:        ((LitP %2):
        !            80:                ($setg DARKG FALSE)
        !            81:                (($ldesc %2))           { Talk about the room }
        !            82:                (($not @DARKG):
        !            83:                        (Llook 1 ($cont %2))    { Talk about its contents }
        !            84:                )
        !            85:        {else}:
        !            86:                ($say "It's mighty dark in here!\n")
        !            87:                ($setg DARKG TRUE)
        !            88:        )
        !            89: 
        !            90: {else} :                        { Level > 0 == This is a list of objs }
        !            91:        ( ($ldesc %2)   :       { Talk (only) about the visible }
        !            92:                (Blank %1)                      { Indent }
        !            93:                (($ldesc %2))           { Blurb the object }
        !            94: 
        !            95:                ( ($cont %2):      { something inside it...}
        !            96:                        (($or ($prop %2 OPEN)($prop %2 TRANS)):
        !            97:                                (Blank %1)
        !            98:                                ($say "It contains:\n")
        !            99:                                ($setp %2 CONTS TRUE)
        !           100:                                (Slook ($plus %1 1) ($cont %2))
        !           101:                                        { Short descriptions for contents }
        !           102:                        )
        !           103:                )
        !           104:         )
        !           105:        (Llook %1 ($link %2))
        !           106: );
        !           107: 
        !           108: 
        !           109: Slook =                         { (Llook Level Object) describes Object }
        !           110: (($eq %2 0) : ($exit 0))
        !           111: (($eq %1 0) :                   { Level 0 == This is a room.  Check lighting }
        !           112:        ((LitP %2):
        !           113:                ($setg DARKG FALSE)
        !           114:                (($sdesc %2))           { Talk about the room }
        !           115:                (($not @DARKG):
        !           116:                        ($setp %2 CONTS FALSE)
        !           117:                        (Slook 1 ($cont %2))    { Talk about its contents }
        !           118:                )
        !           119:        {else}:
        !           120:                ($say "It's mighty dark in here!\n")
        !           121:                ($setg DARKG TRUE)
        !           122:        )
        !           123: 
        !           124: {else} :                        { Level > 0 == This is a list of objs }
        !           125:        (($sdesc %2) :          { Talk (only) about the visible }
        !           126:                (($not ($prop ($loc %2) CONTS)):
        !           127:                        (Blank ($minus %1 1))
        !           128:                        ($say "You can see:\n")
        !           129:                        ($setp ($loc %2) CONTS TRUE)
        !           130:                )
        !           131:                (Blank %1)                      { Indent }
        !           132:                (($sdesc %2))           { Blurb the object }
        !           133:                (($and ($ne ($cont %2) 0)       { something inside it...}
        !           134:                       ($or ($prop %2 OPEN)     {...and you can see it }
        !           135:                            ($prop %2 TRANS)
        !           136:                        )
        !           137:                  ):
        !           138: 
        !           139:                        ($setp %2 CONTS TRUE)
        !           140:                        ($say ", containing:\n")
        !           141:                        (Slook ($plus %1 1) ($cont %2))
        !           142:                                        { Short descriptions for contents }
        !           143:                   :    ($say "\n")
        !           144: 
        !           145:                )
        !           146:        )
        !           147:        ( Slook %1 ($link %2))
        !           148: 
        !           149: );
        !           150: 
        !           151: 
        !           152: 
        !           153: 
        !           154: LOOK =
        !           155: 
        !           156: 
        !           157: 
        !           158:        ($setg WASDK @DARKG)
        !           159:        (@LOOKP :
        !           160:                (($prop ($loc .ME) VISIT):
        !           161:                        (Slook 0 ($loc .ME))
        !           162:                 {else} :
        !           163:                        (Llook 0 ($loc .ME))
        !           164:                        ($setp ($loc .ME) VISIT TRUE)
        !           165:                )
        !           166:                (@DARKG : ($setp ($loc .ME) VISIT FALSE))
        !           167:        )
        !           168:        ($setg LOOKP FALSE)
        !           169:        ($itun)
        !           170:        ($say "\n> ")
        !           171: ;
        !           172: 
        !           173: ROUTINE GrowX; ROUTINE ShrnX;
        !           174: GrowX = (($prop %1 SHRNK):
        !           175:                ($setp %1 SHRNK FALSE)
        !           176:                (($cont %1):
        !           177:                        (GrowX ($cont %1)))
        !           178:                (($link %1):
        !           179:                        (GrowX ($link %1)))
        !           180:        )
        !           181:        ;
        !           182: 
        !           183: Grow = (($prop .ME SHRNK):
        !           184:                ($setp .ME SHRNK FALSE)
        !           185:                (($cont .ME):
        !           186:                        (GrowX ($cont .ME)))
        !           187:        )
        !           188: ;
        !           189: 
        !           190: ShrnX = (($not ($prop %1 SHRNK)):
        !           191:                ($setp %1 SHRNK TRUE)
        !           192:                (($cont %1):
        !           193:                        (ShrnX ($cont %1)))
        !           194:                (($link %1):
        !           195:                        (ShrnX ($link %1)))
        !           196: {else}  :
        !           197:                ($say "You hear a tiny POP as ")(($sdesc %1))
        !           198:                ($say " vanishes completely!\n")
        !           199:                (($link %1):
        !           200:                        (ShrnX ($link %1)))
        !           201:                ($move %1 .ALL)
        !           202:        )
        !           203: 
        !           204: ;
        !           205: 
        !           206: Shrink = (($not ($prop .ME SHRNK)):
        !           207:                ($setp .ME SHRNK TRUE)
        !           208:                (($cont .ME):
        !           209:                        (ShrnX ($cont .ME)))
        !           210:        )
        !           211: ;
        !           212: 
        !           213: WzTgl =                        { Toggle the Wizard flag }
        !           214:        ($setg Wizrd ($not @Wizrd))
        !           215:        (@Wizrd:
        !           216:                ($say
        !           217: "You hear a low rumble of thunder, shaking the very ground on
        !           218: which you stand.  Suddenly, there is a blazing flash of light!!
        !           219: You are unharmed, but feel great power flowing in your body.\n")
        !           220:        {else}:
        !           221:                ($say
        !           222: "Your wizardly powers unceremoniously fade away.\n")
        !           223:        );

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.