Adding the Commands

The AddCommands routine, shown in Listing 14.13, uses code similar to the code I used in the Agent Demo program to initialize the Commands collection (shown earlier, in Listing 14.5).

Listing 14.13: AddCommands Routine in I’m Thinking of a Color

Sub AddCommands()
Dim i As Integer
Dim l As String
TheHost.Commands.Caption = “I’m Thinking of a Color”
TheHost.Commands.Voice = “I’m Thinking of a Color”
TheHost.Commands.Visible = True
TheHost.Commands.Add “cheat”, “cheat”, “what is the color”, True, True
TheHost.Commands.Add “yes”, “yes”, “... yes ...”, True, True
TheHost.Commands.Add “stop”, “stop”, “stop”, True, True
TheHost.Commands.Add Text2.Text, Text2.Text, Text2.Text, True, True
For i = 0 To Combo1.ListCount - 1
   l = Combo1.List(i)
   TheHost.Commands.Add l, l, “... “ & l & “ ...”, True, True
Next i
End Sub

Note that all of these commands belong to TheHost character. Since the user only interacts with the host and none of the other players, the other players don’t need any commands defined.

I added a cheat command, “what is the color”, to help me debug the program, and a stop command that allows me to quickly exit the program. Then I add all of the colors that are contained in the combo box.

© 1998 SYBEX Inc. All rights reserved.