The first method uses ask & answer dialogs in a button on several cards, each card representing a location or "room" along the pathway. The second method uses custom commands in a parser field on one card, similar to the classic game Zork.
1) Any other ideas on how to reproduce one of those old text-based games?
2) The demo includes speech. I'm unsure about proper use of the revUnloadSpeech command. The Dictionary states it is required for a standalone application in a shutdown handler. But if I have two stacks open that both call revLoadSpeech, then close one stack that calls revUnloadSpeech in a closeStack handler, the remaining open stack has no speech engine to use. Calling revLoadSpeech in a resumeStack handler in the stack script doesn't help. if revSpeechVoices() = empty then revLoadSpeech --doesn't work. Once unloaded, speech can't be loaded again until LiveCode is quit and restarted. What am I missing? I'm using Win7, LC6.5.0.
The parser field code and the text game demo v1.1 updated 1/3/2014:
Code: Select all
on returnInField  --parser field code
   local Response
   put last line of me into Response  --load entry
   if Response contains "new game" or Response contains "start over" or Response contains "good-bye" then  --start over
      put "Score: 0" &cr& "Items: " into fld "Display"
      put "> " into line 7 to -1 of me
      select after text of me  --insert cursor
      set the ResponseNumber of me to "1"  --custom property to manage responses
   else if Response contains "vocabulary" or Response contains "words" then
      answer "Game Vocabulary:" &cr& "yes, no, ok, examine, take, use, go, open, close, under, north, south, east, west." with "OK" titled "Info"
   else do ("Parse" & the ResponseNumber of me) && "Response"  --trigger custom commands in correct order
end returnInField
on Parse1 X  --begin, Parse1 is first custom command
   if X contains "yes" or X contains "ok" then
      put cr&cr& "Let's begin a garden adventure with Yellow Cat & Bumblebee!" &cr&\
      "You are Home." &cr& "North is the kitchen, west is the garden." &cr&cr& "> " after me
      select after text of me  --insert cursor
      set the ResponseNumber of me to the ResponseNumber of me + 1  --go Parse2
   else exit to top
end Parse1
on Parse2 X  --n or w
   if X contains "north" or X contains "kitchen" then  --kitchen
      put cr&cr& "Before you can go north to the kitchen you must answer a question." &cr&\
      "What color is the sky on a bright sunny day?" &cr&cr& "> " after me
      select after text of me  --insert cursor
      set the ResponseNumber of me to the ResponseNumber of me + 1  --go Parse3
   else if X contains "west" or X contains "garden" then  --garden
      put cr&cr& "But first you must answer a question before going west to the garden." &cr&\
      "What color is the sky on a bright sunny day?" &cr&cr& "> " after me
      select after text of me  --insert cursor
      set the ResponseNumber of me to the ResponseNumber of me + 3  --go Parse5
   else exit to top
end Parse2
--on Parse3, Parse4, Parse5..., Parse90  --too many custom commands?