DEV website instance!Game initialisationA full size A-code game can have quite large initialisation sections, setting up correct attributes for places, objects and texts. You may wonder why this is being done at run-time, rather than statically, as those entities are being declared. The reason is partly history, but there is also a much stronger reason, why this unusual arrangement persists: it is extremely helpful in guaranteeing upward compatibility of saved games, which, if done correctly, permits game players (and testers!) to upgrade the game withuot invalidating any existing game saves. In this minimalist implementation, though, there are no such attributes to set and this the initialisation code is sweet and short. Here it is, replacing the earlier suggested version: init goto foyer # Move the player to the start location apport cloak, inhand # Give him the cloak apport hook, cloakroom # Put the hook where it belongs set message, 4 # Limits the number of moves in the bar say you.arrive The minor directive GOTO places the player inthe FOYER. The first APPORT moves the object CLOAK to the location INHAND, an automatically defined location for objects held or worn by the player. The second APPORT puts the hook into the cloakroom. (Use of the word "apport" is Platt's little joke – it means transporing an object by occult means, without material agency.) Note, by the way, that all value-bearing entities (objects, places, variables and even some texts) are automatically initialised with value of zero, which for the cloak happens to correspond to being worn by the player. Finally, the SAY directive displays the previously defined named text. This directive is extremely versitile and cen be applied to any entity (text, object, place, vocabulary word) assiciated with text. It can also be applied to variables which point to any such entity. We'll see use of pointer variables later.
|