Skip to content

Instantly share code, notes, and snippets.

@mjm
Created February 4, 2009 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjm/58316 to your computer and use it in GitHub Desktop.
Save mjm/58316 to your computer and use it in GitHub Desktop.
(in-package :hax0r.fork)
(defgame fork-game
(:start-in mansion-foyer)
(:welcome "=== FORK: the cool person's game ===")
(defloc mansion-foyer "a creepy mansion foyer"
(door west other-room))
(defloc other-room "a room inside the creepy mansion"
(door east mansion-foyer))
(defitem sword "for stabbing people"
(:in-room mansion-foyer))
(defitem knife "for cutting things"
(:in-room other-room))
(defcommand (quit q exit leave) ()
(quit-playing)
"Goodbye.")
(defcommand (say speak) ()
(show "You say, \"~{~a~^ ~}.\" Nothing happens." rest))
(defcommand (inv inventory) ()
(format nil "~?"
"You are carrying ~#[nothing~;the ~a~;the ~a and ~a~:;the ~a, ~a~]~#[~:; and ~a~]."
(stringify (get-inventory game))))
(defcommand (pickup carry grab) (item)
(if (carry game item)
(show "You picked up the ~a." item)
(show "You can't carry that.")))
(defcommand (drop) (item)
(if (drop game item)
(show "You dropped the ~a." item)
(show "You aren't carrying that.")))
(defcommand (look) ()
(show "You are in ~a.
~{~&You see a ~a.~}
~{~&There is a ~{~a going ~a~} from here.~}"
(where-am-i game)
(visible-items game)
(mapcar #'(lambda (p)
(list (path-gate p)
(path-type p)))
(paths-from-here game))))
(defcommand (desc describe) (item)
(show "It's ~a." (item-desc item game)))
(defcommand (where) (am i)
(cond ((and (eql 'am am) (eql 'i i)) ; A kludge for multi-word commands
(show "You are in ~a." (where-am-i game)))
(t (command-not-found (list 'where am i)))))
(defcommand (go walk travel) (type)
(if (go-to game (destination-for-type type game))
(execute-command '(look)
game)
(show "You can't go that way."))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment