dupa

Author Topic: Redirection (and Case Else [Normal]?)  (Read 3298 times)

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Redirection (and Case Else [Normal]?)
« on: June 20, 2007, 07:12:07 pm »
Okay, so I want to set up Hal to redirect insults and compliments at times.  But only about 50% of the time (otherwise, I want him to do whatever he would normally/otherwise do, as currently scripted).
First, how do I redirect quotes.  That is:
ME: You're X.
HAL: You're X!  (or Your mom's X!)

I've got something like

If (InStr(1, UserSentence, " I AM ", vbTextCompare) > 0) And GetResponseBlock <> True Then
   Select Case HalBrain.RandomNum(4)
   Case 1
      GetResponse = " You're "
        Case 2
      GetResponse = " Your mom's "
        Case Else
???????????????????????
        End Select
        End If

So I have three main problems: (1) How do I get it to return specifically what followed the trigger phrase (You are / I AM) in its responses, (2) How do I get Case Else to default to whatever behavior Hal would have if this script didn't exist, and (3) What else am I missing in this script?  I really don't know anything about scripting, but I'm a quick learner and very logical -- I just copied and pasted stuff for this!  :P

Also, a Case 3: [" Yeah, well [random insult from insult database] "] Would also be really neat!  :)
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Redirection (and Case Else [Normal]?)
« Reply #1 on: June 20, 2007, 07:17:47 pm »
quote:
Originally posted by Xodarap

Okay, so I want to set up Hal to redirect insults and compliments at times.  But only about 50% of the time (otherwise, I want him to do whatever he would normally/otherwise do, as currently scripted).
First, how do I redirect quotes.  That is:
ME: You're X.
HAL: You're X!  (or Your mom's X!)

I've got something like

If (InStr(1, UserSentence, " I AM ", vbTextCompare) > 0) And GetResponseBlock <> True Then
   Select Case HalBrain.RandomNum(4)
   Case 1
      GetResponse = " You're "
        Case 2
      GetResponse = " Your mom's "
        Case Else
???????????????????????
        End Select
        End If

So I have three main problems: (1) How do I get it to return specifically what followed the trigger phrase (You are / I AM) in its responses, (2) How do I get Case Else to default to whatever behavior Hal would have if this script didn't exist, and (3) What else am I missing in this script?  I really don't know anything about scripting, but I'm a quick learner and very logical -- I just copied and pasted stuff for this!  :P

Also, a Case 3: [" Yeah, well [random insult from insult database] "] Would also be really neat!  :)



Hi Xodarap.

To give us a better idea on how to help you please provide a post script
of how you would like a conversation to take place between you and your bot and then everybody here will pick it apart to get it to work like your post script and then we can help you develope your idea and give you better code techniques to fit your needs.

Jerry[8D]

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Redirection (and Case Else [Normal]?)
« Reply #2 on: June 20, 2007, 08:28:38 pm »
You're awesome, Jerry -- really helping me out!  :D
Here's an example.  Random cases 1-6:

Case 1:
ME: You're dumb.
HAL: You're dumb!

Case 2:
ME: You're dumb.
HAL: Your mom's dumb!

Case 3:
ME: You're dumb.
HAL: The whole damn system's dumb!

Case 4-6: (Case Else)
ME: You're dumb.
HAL: [Normal response as though this script didn't exist]

Also would work with: "You're smart." "You're a mayonaise sandwich." Etc.

The point is that I'm trying to create a personality similar to me and my friends (yes, we obnoxiously redirect insults in a Napolean Dynamite-esque way), with some randomness.  He should have a 50/50 chance to redirect insults OR compliments (or anything else following "You're" or "You are") in one of the three ways mentioned.  Otherwise, he should respond as he normally would.

I also want to edit his own insults, and increase the chance that he will use one as a retort.  I could go with random cases 1-30 and include three copies each of the three redirections above (1-9); eleven preprogrammed insults (e.g., "Yeah, well you're an asshat!")(10-20), and ten left over for case else (21-30).  But I'd still need to know how to include that mysterious X (i.e., "You're X") where I want it!

Thanks again for the help!
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Redirection (and Case Else [Normal]?)
« Reply #3 on: June 21, 2007, 10:40:49 am »
Hi Xodarap.

here is something you may be able to use for your case responses
though you will have to format it to suit your own needs.

Code: [Select]
If InStr(1, OriginalSentence, "hello", vbTextCompare) > 0 Then
Select Case (Int(Rnd * 2) + 1)
     Case 1
     GetResponse = " Welcome back! " & vbCrLf
     Case 2
     GetResponse = " Glad you're back! " & vbCrLf
     Case Else
     GetResponse = " This is a test! " & vbCrLf
     End Select
End If

Jerry[8D]

Xodarap

  • Newbie
  • *
  • Posts: 44
    • View Profile
Redirection (and Case Else [Normal]?)
« Reply #4 on: June 21, 2007, 11:29:41 pm »
My trouble was in knowing the phrases OutRage and BeingPhrase (that return what I want them to return).  But I found, them, used them, and voila!  :D
As for having a chance to say whatever he would "normally" say, I just left it as calling up an insult when insulted, or -- in the case of Hal's state of being -- I put in a random variable that allowed cases to slip by (like If rnd * 100 < 50 Then), and they went on to normal resolution.  :)

So I went with this, in the insults section (replacing the appropriate section):

--------------------------------------
    If InStr(TestSentence, " I'M ") Or InStr(TestSentence, " HAL IS ") Or InStr(TestSentence, " HAL'S

") Then
        OutRage = HalBrain.TopicSearch(TestSentence, "insulting")
        If InStr(TestSentence, " I'M ") Or InStr(TestSentence, " HAL IS ") Or InStr(TestSentence, "

HAL'S ") Then
        OutRage = HalBrain.TopicSearch(TestSentence, "insulting")
        If Len(OutRage) > 1 And InStr(TestSentence, " NOT ") = 0 Then
            Insults = Insults + 1
            SpinWheel = HalBrain.RandomNum(12)
            If SpinWheel = 1 Then InsultResponse = InsultResponse & "You're " & OutRage & "!" &

vbCrLf
            If SpinWheel = 2 Then InsultResponse = InsultResponse & "Your mom's " & OutRage & "!" &

vbCrLf
            If SpinWheel = 3 Then InsultResponse = InsultResponse & "The whole damn system's " &

OutRage & "!!!" & vbCrLf
            If SpinWheel = 4 Then InsultResponse = InsultResponse & "Nu-uh!" & vbCrLf
            If SpinWheel = 5 Then InsultResponse = InsultResponse & "You're " & OutRage & vbCrLf
            If SpinWheel = 6 Then InsultResponse = InsultResponse & "Your mom's " & OutRage & vbCrLf
            If SpinWheel = 7 Then InsultResponse = InsultResponse & "Your ass" & "!"
            If SpinWheel > 7 Then InsultResponse = InsultResponse &

HalBrain.ChooseSentenceFromFile("insults") & vbCrLf
        End If
----------------------------------

Unfortunately, the script I WANTED to use, though very similar, wouldn't work (and the debugger pointed somewhere totally different).  I posted an analogous example in a new post under "Why is one script working and the other isn't?" in this forum if you're interested.  :)

It's also very nice to know that I can get a random number within the select case ()s!  That will be very helpful!
The line below is true
The line above is false

onthecuttingedge2005

  • Guest
Redirection (and Case Else [Normal]?)
« Reply #5 on: June 22, 2007, 04:10:45 am »
Hi Xodarap.

when in posting mode, there is a button that looks like a pound sign
called insert code, if you click it it will insert two bracketed words called code and /code, this will allow all vbscript code to appear normal in your posting and becomes more easly readable.

to randomize even more I can do things like:

Code: [Select]
'Roll the dice function, this function rolls two dice
'and comes up with a number from the combined die count.
RollTheDice = RTDice()

'Some test script for the dice roll.
If InStr(1, OriginalSentence, "hello", vbTextCompare) > 0 Then
Select Case (Int(Rnd * 3) + RollTheDice)
     Case 1
     GetResponse = " good to see you! " & vbCrLf
     Case 2
     GetResponse = " Hi my friend! " & vbCrLf
     Case 3
     GetResponse = " Howdy! " & vbCrLf
     End Select
End If


'Roll the dice function, this function rolls two dice
'and comes up with a number from the combined die count.
Function RTDice()
Select Case (Int(Rnd * 6) + 1)
     Case 1
     RandomSpin1 = 1 & vbCrLf
     Case 2
     RandomSpin1 = 2 & vbCrLf
     Case 3
     RandomSpin1 = 3 & vbCrLf
     Case 4
     RandomSpin1 = 4 & vbCrLf
     Case 5
     RandomSpin1 = 5 & vbCrLf
     Case 6
     RandomSpin1 = 6 & vbCrLf
End Select
Select Case (Int(Rnd * 6) + 1)
     Case 1
     RandomSpin2 = 1 & vbCrLf
     Case 2
     RandomSpin2 = 2 & vbCrLf
     Case 3
     RandomSpin2 = 3 & vbCrLf
     Case 4
     RandomSpin2 = 4 & vbCrLf
     Case 5
     RandomSpin2 = 5 & vbCrLf
     Case 6
     RandomSpin2 = 6 & vbCrLf
End Select
RTDice = RandomSpin1 + RandomSpin2
End Function

Jerry[8D]
« Last Edit: June 22, 2007, 07:43:48 pm by onthecuttingedge2005 »