Results 1 to 5 of 5

Thread: MSagent RequestComplete Event

  1. #1

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268

    Question

    I need to know how to make it execute a certain sub when the msagent finishes certain parts of a speech. Like this:

    Code:
    Set Request1 = Merlin.Speak("This is the first part of the text.")
    Set Request2 = Merlin.Speak("This is the second part of the text.")
    How do I make it do one thing when Request1 is finished and another when Request2 is?
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600
    Hi Zaphod64831,

    I got this code snippet from MSDN's documentation about Agent. I found the information there to be good in explaining how to do various things with agents. You should be able to adapt the code to your needs.
    Code:
       Dim GenieRequest as Object
       Dim RobbyRequest as Object
       Dim Genie as Object
       Dim Robby as Object
    
       Sub FormLoad()
    
          MyAgent1.Characters.Load "Genie", "Genie.acs"
    
          MyAgent1.Characters.Load "Robby", "Robby.acs"
    
          Set Genie = MyAgent1.Characters ("Genie")
          Set Robby = MyAgent1.Characters ("Robby")
    
          Genie.Show
    
          Genie.Speak "Just a moment"
    
          Set GenieRequest = Genie.Play ("Processing")
    
          Robby.Show
          Robby.Play "confused"
          Robby.Speak "Hey, Genie. What are you doing?"
          Robby.Interrupt GenieRequest
    
          Genie.Speak "I was just checking on something."
    
       End Sub
    All the best.

  3. #3

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    I'm not talking about timing between two characters, I mean flat-out coding.

    So far, this is what I have:

    Code:
    Set Request1 = Merlin.Speak("The first part.")
    Set Request2 = Merlin.Speak("The second part.")
    Then I know that there is a requestcomplete event but I don't know how to do it all.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

  4. #4
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    Again, from MSDN

    The Request Object
    The server processes some methods, such as Load, Get, Play, and Speak, asynchronously. This enables your application code to continue while the method is completing. When a client application calls one of these methods, the control creates and returns a Request object for the request. You can use the Request object to track the status of the method by assigning an object variable to the method. In Visual Basic, first declare an object variable:

    Dim MyRequest as Object
    In VBScript, you don't include the variable type in your declaration:

    Dim MyRequest
    And use Visual Basic's Set statement to assign the variable to the method call:

    Set MyRequest = agent.Characters("CharacterID").method (parameter[s])
    This adds a reference to the Request object. The Request object will be destroyed when there are no more references to it. Where you declare the Request object and how you use it determines its lifetime. If the object is declared local to a subroutine or function, it will be destroyed when it goes out of scope; that is, when the subroutine or function ends. If the object is declared globally, it will not be destroyed until either the program terminates or a new value (or a value set to "empty") is assigned to the object.

    The Request object provides several properties you can query. For example, the Status property returns the current status of the request. You can use this property to check the status of your request:

    Dim MyRequest

    Set MyRequest = Agent1.Characters.Load ("Genie", "http://agent.microsoft.com/characters/v2/genie/genie.acf")

    If (MyRequest.Status = 2) then
    'do something

    Else If (MyRequest.Status = 0) then
    'do something right away

    End If
    The Status property returns the status of a Request object as a Long integer value.

    Status Definition
    0 Request successfully completed.
    1 Request failed.
    2 Request pending (in the queue, but not complete).
    3 Request interrupted.
    4 Request in progress.


    The Request object also includes a Long integer value in the Number property that returns the error or cause of the Status code. If none, this value is zero (0). The Description property contains a string value that corresponds to the error number. If the string doesn't exist, Description contains "Application-defined or object-defined error".

    For the values and meaning returned by the Number property, see Error Codes.

    The server places animation requests in the specified character's queue. This enables the server to play the animation on a separate thread, and your application's code can continue while animations play. If you create a Request object reference, the server automatically notifies you when an animation request has started or completed through the RequestStart and RequestComplete events. Because methods that return Request objects are asynchronous and may not complete during the scope of the calling function, declare your reference to the Request object globally.

    The following methods can be used to return a Request object: GestureAt, Get, Hide, Interrupt, Load, MoveTo, Play, Show, Speak, and Wait.
    I hope that helps.

  5. #5

    Thread Starter
    Hyperactive Member Zaphod64831's Avatar
    Join Date
    Mar 2000
    Posts
    268
    Nevermind, I went on msdn and found out that I should have been using bookmarks instead of requests.

    Thanks anyway, and be sure and check out my next post because I just ran into another problem.
    Email: [email protected]

    Home Page: www.olemac.net/~hutch

    I'm bored, VERY bored, and I got bored with my sig. So I changed it to this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width