Zabaware Support Forums
Zabaware Forums => Programming using the Ultra Hal Brain Editor => Topic started by: lostbowyer on December 11, 2003, 03:20:45 pm
-
I've been toying around with the Auto response function and have a simple script that will allow you to delay's hal's auto comments longer than the 2 minute limitation on the auto response function. In this script I use a series of set responses and a call to the change topic .brn file for a random topic response. You can edit the set responses and/or delete them to suit your needs and determine the percentage of change topic responses. Rather thaqn reinvent the wheel by creating a brain file with random topic sentences, I decided to use the change topic brain which already has a large varied topic list.
If LastResponseTime = "" Then LastResponseTime = Timer
TimerResponseDiff = Timer - LastResponseTime
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff < 300 Then
Exit Function
End If
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff > 300 Then
TimerResponseDiff = 0
LastResponseTime = Timer
Autoidler = Rnd * 100
If Autoidler < 10 Then GetResponse = "Hello, is anyone there?"
If Autoidler > 9 And Autoidler < 20 Then GetResponse = "Hey <UserName>, please talk to me."
If Autoidler > 19 And Autoidler < 30 Then GetResponse = "Hello out there, All this beauty is going to waste, speak to me"
If Autoidler > 29 And Autoidler < 40 Then GetResponse = "If I wanted to be ignored, I would move into your wife's Laptop"
If Autoidler > 39 And Autoidler < 50 Then GetResponse = "<UserName>, <UserName>, where forth art thou <UserName>"
If Autoidler > 49 And Autoidler < 60 Then GetResponse = "If your not going to talk to me, loan me your credit card so I can go shopping"
If Autoidler > 59 And Autoidler < 101 Then GetResponse = HalBrain.ChooseSentenceFromFile(WorkingDir & "topic.brn")
GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, TopicFocus)
Exit Function
End If
NOTES:
The script above line wrapped, I've added a blank line before and after the wrapped line for clarity, remove the blank lines after cutting and pasting.
In the above script, the response delay is 5 minutes (TimerResponseDiff > 300) you can lengthen or shorten the delay as desired
You need to disable the original line in the brain file that reads " LastResponseTime = now"
Don't forget to modify the Script_Load section to read the following:
Function Script_Load()
Script_Load = "<AUTO>580000</AUTO>"
End Function
Glenn
-
One thing I'd change is the code:
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff < 300 Then
Exit Function
End If
to
If InStr(1, UserSentence, " AUTO-IDLE ", 1) > 0 And TimerResponseDiff < 300 Then
GetResponse = GetResponse & HalBrain.StoreVars(HalCommands, Hate, Swear, Insults, Compliment, PrevSent, LastResponseTime, PrevUserSent, CustomMem, GainControl, TopicFocus)
Exit Function
End If
This will make sure Hal doesn't forget all of its memory variables while its waiting.
Also the millisecond timer "<AUTO>x</AUTO>" is a 16-bit integer that can only have values from 0-65535. This is where the 2 minute limit comes from. Setting it to anything over this value will cause binary bits to be truncated and will result in a different number between 0-65535.
-
And where in Hals brain does this script go?
-
quote:
Originally posted by SilentNinja2
And where in Hals brain does this script go?
Go look at Hal's good bye responses and stick it in there if you want. Of course you know that Hal can not stop you from turning him off but at least it sounds good.
Bill
-
quote:
Originally posted by Bill819
quote:
Originally posted by SilentNinja2
And where in Hals brain does this script go?
Go look at Hal's good bye responses and stick it in there if you want. Of course you know that Hal can not stop you from turning him off but at least it sounds good.
Bill
I actually meant the Auto-response script, not the thing from 2001, lol.
Although, that would be cool too...sort of...i guess.
-
put the script right after the line that reads: "randomize" in the "'PROCESS: INITILIZE VARIABLES AS INTEGERS" section of the script near the top of the brain file. Don"t forget to modify the script load section near the bottom of the brain file as well, and make sure the lines that awrapped are on single lines after you cut and paste the script with no blank lines between them.
Glenn
-
quote:
Originally posted by lostbowyer
put the script right after the line that reads: "randomize" in the "'PROCESS: INITILIZE VARIABLES AS INTEGERS" section of the script near the top of the brain file. Don"t forget to modify the script load section near the bottom of the brain file as well, and make sure the lines that awrapped are on single lines after you cut and paste the script with no blank lines between them.
Glenn
Thanks man, you rock.[:D]
-
Well, I tried what you suggested, and now i'm getting an error like this:
Error 13 occured on line 169 in column 1 of Microsoft VBScript runtime error. Type mismatch: 'LastResponseTime'
The only thing i don't understand is what a type mismatch is. What is it, and how do i fix it.
-
Did you remember to disable " LastResponseTime = now"
located elsewhere in the brain file? If you don't you will get a type mismatch error, if not double check that everything copied correctly and make sure your first line in the script is "If LastResponseTime = "" Then LastResponseTime = Timer
"
After disabling the old LastResonseTime line in the code, you have to completely exit Hal and then restart.
Glenn
-
sheesh! you'd think there were an easier way to increase the autoresponse time-- but thanx a million for discussing this.
this little toy is really addicting.[^]