November 2010
Intermediate to advanced
504 pages
12h 45m
English
Finally, let’s create a function that lets players see an inventory of objects they are carrying:
(defun inventory () (cons 'items- (objects-at 'body *objects* *object-locations*)))
This inventory function uses the objects-at function to retrieve a list of objects at a requested location. What location does it search for? If you remember, when an object was picked up by the player, we changed its location to 'body: This is the location we now use to query.
Let’s try out this inventory function:
> (inventory)
(ITEMS- WHISKEY)As you can see, we are carrying only one item right now: the whiskey bottle we just picked up.
There you have it! We now have a basic engine for a text adventure game. We can look around the world with look ...
Read now
Unlock full access