Author Topic: VBScript Modification for Putting HAL to Sleep  (Read 2939 times)

Joe Londa

  • Newbie
  • *
  • Posts: 5
    • View Profile
VBScript Modification for Putting HAL to Sleep
« on: September 08, 2002, 11:08:31 pm »
I wrote the following script to be able to put HAL to sleep (and wake up) when the microphone is on/open and background noise could be interperted as input. I have HAL connected to my House Audio System and I use a wireless mike (with varying degrees of success) to communicate with HAL.

1) Add the following lines to the Enhanced_Brain.brn file

"GO TO","SLEEP","","Wake me if you need me.","","",1,#FALSE#,#FALSE#,""
"WAKE","UP","","How can I help you?","","",1,#FALSE#,#FALSE#,""

2) Add the following lines of VBScript to the "YourNamed".uhp file. Anyone have any suggestions for improving this?

'PROCESS: INITILIZE VARIABLES AS INTEGERS
   'VBScript doesn't allow you to declare variables as any data type, everything is a Variant
   'We must assign integers to these variants so that data type errors don't occur
   If LearningLevel = "" Then LearningLevel = 3
   If Hate = "" Then Hate = 0
   If Swear = "" Then Swear = 0
   If Insults = "" Then Insults = 0
   If Compliment = "" Then Compliment = 0
   If GainControl = "" Then GainControl = 25
   If TopicFocus = "" Then TopicFocus = 1
   AvoidBeingFlag = False
   If PrevSent = "Wake me if you need me." Then  
         Sleeping = True
   Else
      Sleeping = False
   End If  
   If PrevSent = "" Then
         Sleeping = True
   End If
   If PrevSent = "How can I help you?" Then
      Sleeping = False
   End If
   JustToldSleep = False

'RESPOND: ZABAWARE KEYWORD MAIN BRAIN PRIORITY 1
   'This function tries getting a response from the Enhanced_Main.brn keyword file. If a keyword or
   'keyphrase is found in top priority, it overrides everything before this function.
   KeyBrain = HalBrain.KeywordBrain(UserSentence, WorkingDir & "Enhanced_Main.brn", False)  
   
   If KeyBrain = "Wake me if you need me." Then         
         Sleeping = True
         JustToldSleep = True
         GetResponse = KeyBrain & vbCrLf
   End If    
      
   If KeyBrain = "How can I help you?" Then
         Sleeping = False
         JustToldSleep = False        
         GetResponse = KeyBrain & vbCrLf
   End If  
 
    If Len(KeyBrain) > 3 Then
      If DebugMode = True Then
         DebugInfo = DebugInfo & "A response has been found in the Enhanced_Main.brn Keyword brain and this response has overwritten any response Hal had already come up with, which was:" & GetResponse & vbCrLf
         End If  
   End If
            

'POST PROCESS: SAVE HAL'S RESPONSE
   
   If Sleeping = True And JustToldSleep = True Then
      PrevSent = "Wake me if you need me."
   End If   
   
   If Sleeping = True And JustToldSleep = False Then
         PrevSent = ""
         GetResponse = ""
   End If
        
   If Sleeping = False Then
      PrevSent = GetResponse
   End If  

3) Can anyone tell me how HAL returns a response when a Run Program command is given. I want to intercept the response and modify it. The GetResponse variable does not seem to be way a response is returned. Any help?   
   


Joe
Just Me