Annotation of 42BSD/games/ddl/doc/builtins.ms, revision 1.1

1.1     ! root        1: .NH
        !             2: Built-in Functions
        !             3: .PP
        !             4: The following functions are built-in functions available to the 
        !             5: \s-2DDL\s+2
        !             6: programmer.  These functions are the heart of the 
        !             7: \s-2DDL\s+2 
        !             8: system and are
        !             9: the means whereby the 
        !            10: \s-2DDL\s+2 
        !            11: routines manipulate all system data.  Thus,
        !            12: these functions completely describe the facilities of the 
        !            13: \s-2DDL\s+2 
        !            14: system.
        !            15: .NH 2
        !            16: Functions on objects
        !            17: .IP "\fB$loc    \fR" 8
        !            18: ($loc \fIobj\fR) \(-> The container of \fIobj\fR.
        !            19: .IP "\fB$cont   \fR" 8
        !            20: ($cont \fIobj\fR) \(-> First item contained in \fIobj\fR.
        !            21: .IP "\fB$link   \fR" 8
        !            22: ($link \fIobj\fR) \(-> The next object in the same node as \fIobj\fR.
        !            23: .IP "\fB$ldisc  \fR" 8
        !            24: ($ldisc \fIobj\fR) \(-> The routine ID for the long description of \fIobj\fR.
        !            25: .IP "\fB$sdisc  \fR" 8
        !            26: ($sdisc \fIobj\fR) \(-> The routine ID for the short description of \fIobj\fR.
        !            27: .IP "\fB$rtn    \fR" 8
        !            28: ($rtn \fIobj\fR) \(-> The ACTION routine for \fIobj\fR.
        !            29: .IP "\fB$prop   \fR" 8
        !            30: ($prop \fIobj\fR \fIpropnum\fR) \(-> returns the value of the \fIpropnum\fR'th property
        !            31: of \fIobj\fR.
        !            32: .NH 2
        !            33: Arithmetic Funcions
        !            34: .IP "\fB$plus   \fR" 8
        !            35: ($plus \fIarg1\fR \fIarg2\fR) \(-> \fIarg1\fR+\fIarg2\fR
        !            36: .IP "\fB$minus  \fR" 8
        !            37: ($minus \fIarg1\fR \fIarg2\fR) \(-> \fIarg1\fR-\fIarg2\fR
        !            38: .IP "\fB$times  \fR" 8
        !            39: ($times \fIarg1\fR \fIarg2\fR) \(-> \fIarg1\fR*\fIarg2\fR
        !            40: .IP "\fB$quotient \fR" 8
        !            41: ($quotient \fInum den\fR) \(-> [\fInum\fR/\fIden\fR]
        !            42: .IP "\fB$remainder \fR" 8
        !            43: ($remainder \fInum den\fR) \(-> \fInum\fB mod \fIden\fR
        !            44: .IP "\fB$rand \fR" 8
        !            45: ($rand \fIarg\fR) \(-> Random integer between 1 and \fIarg\fR inclusive
        !            46: .NH 2
        !            47: Boolean Functions
        !            48: .IP "\fB$and    \fR" 8
        !            49: ($and \fIa b\fR) \(-> \fIa\fB (bitwise AND) \fIb\fR
        !            50: .IP "\fB$or     \fR" 8
        !            51: ($or \fIa b\fR) \(-> \fIa\fB (bitwise OR) \fIb\fR
        !            52: .IP "\fB$not    \fR" 8
        !            53: ($not \fIx\fR) \(->  \s-2IF\s+2 \fIx\fR nonzero \s-2THEN\s+2 zero \s-2ELSE\s+2 one.
        !            54: .IP "\fB$yorn   \fR" 8
        !            55: ($yorn) \(-> Waits for the Player to type a line of input.  Returns
        !            56: one if the Player types "yes" or "y" and zero otherwise.
        !            57: .IP "\fB$pct    \fR" 8
        !            58: ($pct \fIprob\fR) \(-> Returns one, \fIprob\fR% of the time, zero otherwise.
        !            59: .IP "\fB$eq     \fR" 8
        !            60: ($eq \fIarg1\fR \fIarg2\fR) \(-> 1 if \fIarg1\fR equals \fIarg2\fR, zero otherwise.
        !            61: .IP "\fB$ne     \fR" 8
        !            62: ($ne \fIarg1\fR \fIarg2\fR) \(-> IF \fIarg1\fR ~= \fIarg2\fR THEN  one  ELSE  zero.
        !            63: .IP "\fB$lt     \fR" 8
        !            64: ($lt \fIarg1\fR \fIarg2\fR) \(-> 1 if \fIarg1\fR < \fIarg2\fR, zero otherwise.
        !            65: .IP "\fB$gt     \fR" 8
        !            66: ($gt \fIarg1\fR \fIarg2\fR) \(-> 1 if \fIarg1\fR > \fIarg2\fR, zero otherwise.
        !            67: .IP "\fB$le     \fR" 8
        !            68: ($le \fIarg1\fR \fIarg2\fR) \(-> 1 if \fIarg1\fR <= \fIarg2\fR, zero otherwise.
        !            69: .IP "\fB$ge     \fR" 8
        !            70: ($ge \fIarg1\fR \fIarg2\fR) \(-> 1 if \fIarg1\fR >= \fIarg2\fR, zero otherwise.
        !            71: .NH 2
        !            72: Builtin Procedures (no return value)
        !            73: .IP "\fB$setg    \fR" 8
        !            74: ($setg \fIglobalnumber value\fR) \(-> No return value.  Sets the
        !            75: contents of global #\fIglobalnumber\fR to \fIvalue\fR.
        !            76: .IP "\fB$setp   \fR" 8
        !            77: ($setp \fIobj propnum value\fR) \(-> No return value.  Sets the \fIpropnum\fR'th
        !            78: property of \fIobj\fR to \fIvalue\fR.  Note that properties 1-16 may only contain 0 or 1.
        !            79: .IP "\fB$move   \fR" 8
        !            80: ($move \fIobj dest\fR) \(-> No return value.  Causes \fIobj\fR to be placed
        !            81: inside \fIdest\fR, and adjusts pointers accordingly.  \fBDanger\fR: No checking is
        !            82: performed to verify that $move is not being used to violate the tree structure
        !            83: of the object list (eg ($move obj obj)).
        !            84: Bad results are likely if this occurs.
        !            85: .IP "\fB$say    \fR" 8
        !            86: ($say \fImsg\fR) \(-> No return value.  Types \fImsg\fR.
        !            87: .IP "\fB$name   \fR" 8
        !            88: ($name \fIobj\fR) \(-> No return value.  Types the (5-letter) name of \fIobj\fR.
        !            89: .IP "\fB$num    \fR" 8
        !            90: ($num \fIx\fR) \(-> No return value.  Types the number \fIx\fR.
        !            91: .IP "\fB$exit   \fR" 8
        !            92: ($exit \fIn\fR) \(-> Leave present routine.  ($exit 1) causes the current
        !            93: "turn" to be prematurely terminated and the next turn to be initiated
        !            94: at the Demon phase.  ($exit 0) returns to the driver to begin the next phase.
        !            95: .IP "\fB$rtrn   \fR" 8
        !            96: ($rtrn \fIn\fR) \(-> Exits to the calling routine, returning value '\fIn\fR' TO
        !            97: THE CALLING FUNCTION.
        !            98: .IP "\fB$spec   \fR" 8
        !            99: ($spec \fIcode arg1 arg2 arg3 arg4\fR) \(-> Performs a special function as
        !           100: follows:
        !           101: .TS
        !           102: center box;
        !           103: c | c.
        !           104: code   function
        !           105: =
        !           106: 3      Terminate this run of DDL
        !           107: _
        !           108: 4      Save a game
        !           109: _
        !           110: 5      Restore a game
        !           111: _
        !           112: 7      Preserve unknown words in file \fIarg1\fR
        !           113: .TE
        !           114: .PP
        !           115: Functions 4 and 5 prompt for a file name in which the saved game is
        !           116: kept.  Function 7 causes any unknown words encountered by the parser
        !           117: to be preserved in a file for later perusal by the 
        !           118: \s-2DDL\s+2 
        !           119: programmer.  It
        !           120: would be used to learn about things players have tried unsuccessfully
        !           121: that should be dealt with.  The file must already exist, and must
        !           122: be specified as a string.
        !           123: .PP
        !           124: ALL arguments must be specified, even if zero.
        !           125: .NH 2
        !           126: Global-value functions
        !           127: .IP "\fB$glob   \fR" 8
        !           128: ($glob \fIn\fR) \(-> Value of global \fIn\fR.  Equivalent to @\fIn\fR.
        !           129: .IP "\fB$verb   \fR" 8
        !           130: ($verb) \(-> The ID of the verb returned by the parser (zero if none).
        !           131: Typically used in comparisons, it is equivalent to @Verb.
        !           132: .IP "\fB$dobj   \fR" 8
        !           133: ($dobj) \(-> The ID of the direct object returned by the parser
        !           134: (zero if none).  Equivalent to @Dobj.
        !           135: .IP "\fB$iobj   \fR" 8
        !           136: ($dobj) \(-> The ID of the indirect object returned by the parser
        !           137: (zero if none).  Equivalent to @Iobj.
        !           138: .NH 2
        !           139: Transition Procedures
        !           140: .IP "\fB$setv   \fR" 8
        !           141: ($setv \fIv1 v2 v3 v4 v5 v6 v7 v8 v9 v10\fR) \(-> sets the values in
        !           142: the internal vector VECVERB to the values \fIv1\fR thru \fIv10\fR.  These are
        !           143: used by routines $hit and $miss.
        !           144: .IP "\fB$hit    \fR" 8
        !           145: ($hit \fImover d1 d2 d3 d4 d5 d6 d7 d8 d9 d10\fR) \(-> No return value.
        !           146: Compares ($verb) with the values in builtin vector VECVERB.  When ($verb)
        !           147: is found to match the nth entry in VECVERB, ($move \fImover d[n]\fR) is executed.
        !           148: Note that \fImover\fR is what gets moved to d[n]; this argument is naturally
        !           149: absent from $setv and $miss.
        !           150: .IP "\fB$miss   \fR" 8
        !           151: ($miss \fIr1 r2 r3 r4 r5 r6 r7 r8 r9 r10\fR) \(-> no return value.
        !           152: Compares ($verb) to VECVERB as $hit does.  When a match to the nth
        !           153: entry in VECVERB is found, routine \fIr\fR[n] is called.  An attempt to
        !           154: call routine 0 does nothing.
        !           155: .NH 2
        !           156: String Functions
        !           157: .PP
        !           158: There are two varieties of strings.  Constant strings defined
        !           159: by the DDL programmer are permanent, and have a numeric "value"
        !           160: greater than zero (which is in fact a table index).  Strings
        !           161: typed by the Player as a direct object, and strings produced
        !           162: by the functions $eqst and $read are temporary, have a numeric
        !           163: "value" less than zero (which allows the programmer to determine
        !           164: if the direct object is in fact a string), and are purged by
        !           165: having their index values recycled at the beginning of every turn.
        !           166: No more than 200 such strings may be generated on a given turn.
        !           167: .IP "\fB$eqst\fR" 8
        !           168: ($eqst \fIarg1 arg2\fR) \)-> 1 iff the strings specified by the
        !           169: two \fIarg\fRs are equal, zero otherwise.
        !           170: .IP "\fB$subs\fR" 8
        !           171: ($subs \fIstr index length\fR) \)-> a string consisting of the
        !           172: substring of \fIstr\fR, starting at character \fIindex\fR 
        !           173: (with an origin of Zero for the beginning of the string), for
        !           174: the specified \fIlength\fR.  A \fIlength\fR of zero causes
        !           175: all the remaining characters starting at \fIindex\fR to be
        !           176: taken.
        !           177: .IP "\fB$leng\fR" 8
        !           178: ($leng \fIstr\fR) \)-> The length of string \fIstr\fR.
        !           179: .IP "\fB$read\fR" 8
        !           180: ($read) \)-> Causes \s-2DDL\s+2 to pause and wait for input from
        !           181: the Player.  Returns the string the player typed, without the
        !           182: trailing newline.
        !           183: .NH 2
        !           184: Demons and Fuses
        !           185: .IP "\fB$sdem   \fR" 8
        !           186: ($sdem n) \(-> Activates routine n as a Demon, to be executed every
        !           187: turn.  At least one such Demon should exist, to Look at the Player's
        !           188: current location, and to increment the turn counter
        !           189: .IP "\fB$ddem   \fR" 8
        !           190: ($ddem n) \(-> Removes routine n from the active Demon list.  For
        !           191: example, ($ddem Kount) undoes the action of ($sdem Kount).
        !           192: .IP "\fB$sfus   \fR" 8
        !           193: ($sfus rout n) \(-> Causes routine "rout" to be executed (one
        !           194: time only) after n turns.  Such a routine is called a Fuse.
        !           195: .IP "\fB$dfus   \fR" 8
        !           196: ($dfus rout) \(-> Causes routine rout to be taken off the
        !           197: pending fuse list.
        !           198: .IP "\fB$itun   \fR" 8
        !           199: ($itun) \(-> Increments the turn counter.  This is a builtin function
        !           200: because fuses depend upon the turn counter.  The 
        !           201: \s-2DDL\s+2 
        !           202: programmer has the
        !           203: option to "slow time" by refraining from incrementing the turn counter.
        !           204: .IP "\fB$gtun   \fR" 8
        !           205: ($gtun) \(-> Returns the current turn counter value.

unix.superglobalmegacorp.com

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