! STDLIB.INC: A collection of useful subroutines. ! ! This file is in the public domain. ! ! To use this file, place "#include stdlib.inc" near the beginning ! of your game. ! ! This file defines three variables for internal use: ! [loop routine] (used to pass your subroutines the the subroutines ! in this library) ! [arg] (used to hold arguments to subroutines, both yours and ! the ones in this library) ! ! [arg2] Like above. ! ! [arg3] Ditto ! ! At the moment, there are only two subroutines here: ! ! [object loop]: Does something to every noun, and creature in ! the game. To use, write a subroutine that does whatever you want ! to the object contained in [arg]. Then set the variable ! [loop routine] to equal this subroutine and invoke [object loop]. ! See MANSION.AGT for an example. ! ! [creature loop]: Like the object loop, but only does things to creatures. ! Use it like you would object loop. ! ! subroutines [object loop] [creature loop] end_subroutines variable [loop routine] variable [arg] variable [arg2] variable [arg3] ! Subroutine to loop over all nouns and creatures in the game ! Set [loop routine] to the subroutine to call for each object. ! The variable [arg] will contain the current object. COMMAND SUBROUTINE[object loop] Set [arg] [magx:first noun] 1 2 GT [arg] [magx:last noun] ! If we reach end of nouns, start creats LT [arg] [magx:first creature] Set [arg] [magx:first creature] 2 GT [arg] [magx:last creature] ! If last creature, we're done Return 2 DoSubroutine [loop routine] Add [arg] 1 Prev 1 END_COMMAND COMMAND SUBROUTINE[creature loop] Set [arg] [magx:first creature] 1 2 GT [arg] [magx:last creature] ! If last creature, we're done Return 2 DoSubroutine [loop routine] Add [arg] 1 Prev 1 END_COMMAND