Zabaware Support Forums

Zabaware Forums => Programming using the Ultra Hal Brain Editor => Topic started by: systemshock on February 07, 2013, 07:02:39 pm

Title: magic 8 ball plug in HELP!
Post by: systemshock on February 07, 2013, 07:02:39 pm
Hi  I play been poking around plug ins....
this is a base plug in for  tarot reading and some cold reading stuff...

Goal: to get this working ...
Then to add shiny..
You know add some full body .haps animations and may be a oog for mystic music and ball rattal..
sort got that already in my modded vr haptec  ;D

Here my not working yet plug code just cant work out 
the f***ING missing statement error..on line have a guess/i].

Can any body spot it...i have gone code blind... 8)/...

IT NOT FLYING YET SO Don't just don't ok....


Rem Type=Plugin
Rem Name=Magic 8 Ball plug in v1
Rem Author= SystemShock
Rem Host=Assistant


'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "a magic 8 ball toy ...triggered by ..play magic eight ball"
    lblPlugin(0).Move 120, 120, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
    cmdPlugin(0).Move 800, 1300, 2100, 375
    cmdPlugin(0).Caption = "build one"
    cmdPlugin(0).Visible = True
End Sub



'-------------------------------------------------------------------------------------------------------
    Rem PLUGIN: CUSTOMMEM2
    'The comment above tells Ultra Hal Assistant to insert the following code
    'on-the-fly into the main brain code in the section referenced.
'------------------
' Variables Setup
' all my variables have the prefix EIGHTball for this plugin. ;)
'------------------
DiagnosticsrSentence = LCase(UserSentence)
EIGHTballFile    = ""
EIGHTballHalCommands    = ""
Diagnostics   =""

'------------------
' plug in bit...;) useing variables set up^^^^^ there^^^^^
'  Diagnostics
'------------------
  If InStr(1, OriginalSentence, "use you magic eight ball ", 1) Or _
       InStr(1, OriginalSentence, "play magic eight ball", 1) Then Diagnostics = True
   
    'Here we can add accociated responses to the above triggers.
    If Diagnostics = True Then
                 GetResponse = "focus on your question, are you ready to play magic eight ball boss? "
            
     End If
   
If PrevSent = "focus on your question are you ready to play magic eight ball boss?" Then
             If Yes(OriginalSentence) = True Then GetResponse = "OK Boss her we go, and the magic eight ball says?"

' ball code goes here mate
Select Case HalBrain.RandomNum(21)
Case 1
GetResponse = "It is certain" & vbCrLf
Case 2
GetResponse = "It is decidedly so" & vbCrLf
Case 3
GetResponse =  "Without a doubt" & vbCrLf
Case 4
GetResponse = "Yes – definitely" & vbCrLf
Case 5
GetResponse = "You may rely on it" & vbCrLf
Case 6
GetResponse = "As I see it, yes" & vbCrLf
Case 7
GetResponse = "Most likely" & vbCrLf
Case 8
GetResponse = "Outlook good" & vbCrLf
Case 9
GetResponse = "Yes" & vbCrLf
Case 10
GetResponse = "Signs point to yes" & vbCrLf
Case 11
GetResponse = "Reply hazy, try again" & vbCrLf
Case 12
GetResponse = "Ask again later" & vbCrLf
Case 13
GetResponse = "Better not tell you now" & vbCrLf
Case 14
GetResponse = "Cannot predict now" & vbCrLf
Case 15
GetResponse = "Concentrate and ask again" & vbCrLf
Case 16
GetResponse = "Don't count on it" & vbCrLf
Case 17
GetResponse = "My reply is no" & vbCrLf
Case 18
GetResponse = "My sources say no" & vbCrLf
Case 19
GetResponse = "Outlook not so good" & vbCrLf
Case 20
GetResponse = "Very doubtful" & vbCrLf
Case 21
GetResponse = "oh,**** I dropped it, sorry boss!"& vbCrLf
                         End Select
Else
           
         
             If No(OriginalSentence) = True Then GetResponse = "OK i put it away then Boss."
             If Maybe(OriginalSentence) = True Then GetResponse = "if that the case I put it away ask me again some time. "
    End If
            


Rem PLUGIN: FUNCTIONS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.

'Here we can use the Yes, No, Maybe functions throughout the entire script
'to direct our questions and answers more efficiently.

'direct Yes affirmation
Function Yes(OriginalSentence)
Yes = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yes ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " affirmative ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yep ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yup ", 1) Then Yes = True
End Function
'direct No affirmation
Function No(OriginalSentence)
No = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " no ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " nope ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " it is not ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " negative ", 1) Then No = True
End Function
'if the user is not certain about the question then assume they are not certain.
Function Maybe(OriginalSentence)
Maybe = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't know ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't believe so ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't think so ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i'm not sure ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i never checked ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i didn't check ", 1) Then Maybe = True
End Function


--- End code ---

Title: Re: magic 8 ball plug in HELP!
Post by: owensyeliza on April 08, 2013, 01:39:46 pm
Thanks! I will try this out.
Title: Re: magic 8 ball plug in HELP!
Post by: cload on April 09, 2013, 12:48:12 pm
HI SYSTEM SHOCK,
AFTER FIXING 5 PROBLEMS THAT I FOUND, IT SEEMS TO BE WORKING OKAY, NOW HERE IS THE NEW CODE, HAVE FUN.
Code: [Select]
Rem Type=Plugin
Rem Name=Magic 8 Ball plug in v1
Rem Author= SystemShock
Rem Host=Assistant


'This sub setups the plug-ins option panel in Hal's options dialog
Sub OptionsPanel()
    lblPlugin(0).Caption = "a magic 8 ball toy ...triggered by ..play magic eight ball"
    lblPlugin(0).Move 120, 120, 3300, 1000
    lblPlugin(0).WordWrap = True
    lblPlugin(0).Visible = True
    cmdPlugin(0).Move 800, 1300, 2100, 375
    cmdPlugin(0).Caption = "build one"
    cmdPlugin(0).Visible = True
End Sub



'-------------------------------------------------------------------------------------------------------
Rem PLUGIN: CUSTOMMEM2
    'The comment above tells Ultra Hal Assistant to insert the following code
    'on-the-fly into the main brain code in the section referenced.
'------------------
' Variables Setup
' all my variables have the prefix EIGHTball for this plugin. ;)
'------------------
DiagnosticsrSentence = LCase(UserSentence)
EIGHTballFile    = ""
EIGHTballHalCommands    = ""
Diagnostics   =""

'------------------
' plug in bit...;) useing variables set up^^^^^ there^^^^^
'  Diagnostics
'------------------
If InStr(1, OriginalSentence, "eight ball", 1) >0 Then Diagnostics = "True"
   
'Here we can add accociated responses to the above triggers.
If Diagnostics = "True" Then
GetResponse = "focus on your question, are you ready to play magic eight ball boss? "
End If
   
If PrevSent = "focus on your question are you ready to play magic eight ball boss?" Then
If Yes(OriginalSentence) = True Then GetResponse = "OK Boss her we go, and the magic eight ball says?"
' ball code goes here mate
Select Case HalBrain.RandomNum(21)
Case 1 GetResponse = "It is certain" & vbCrLf
Case 2 GetResponse = "It is decidedly so" & vbCrLf
Case 3 GetResponse =  "Without a doubt" & vbCrLf
Case 4 GetResponse = "Yes – definitely" & vbCrLf
Case 5 GetResponse = "You may rely on it" & vbCrLf
Case 6 GetResponse = "As I see it, yes" & vbCrLf
Case 7 GetResponse = "Most likely" & vbCrLf
Case 8 GetResponse = "Outlook good" & vbCrLf
Case 9 GetResponse = "Yes" & vbCrLf
Case 10 GetResponse = "Signs point to yes" & vbCrLf
Case 11 GetResponse = "Reply hazy, try again" & vbCrLf
Case 12 GetResponse = "Ask again later" & vbCrLf
Case 13 GetResponse = "Better not tell you now" & vbCrLf
Case 14 GetResponse = "Cannot predict now" & vbCrLf
Case 15 GetResponse = "Concentrate and ask again" & vbCrLf
Case 16 GetResponse = "Don't count on it" & vbCrLf
Case 17 GetResponse = "My reply is no" & vbCrLf
Case 18 GetResponse = "My sources say no" & vbCrLf
Case 19 GetResponse = "Outlook not so good" & vbCrLf
Case 20 GetResponse = "Very doubtful" & vbCrLf
Case 21 GetResponse = "oh,**** I dropped it, sorry boss!" & vbCrLf
End Select
Else
If No(OriginalSentence) = True Then GetResponse = "OK i put it away then Boss."
If Maybe(OriginalSentence) = True Then GetResponse = "if that the case I put it away ask me again some time. "
End If
             


Rem PLUGIN: FUNCTIONS
'The preceding comment is actually a plug-in directive for
'the Ultra Hal host application. It allows for code snippets
'to be inserted here on-the-fly based on user configuration.

'Here we can use the Yes, No, Maybe functions throughout the entire script
'to direct our questions and answers more efficiently.

'direct Yes affirmation
Function Yes(OriginalSentence)
Yes = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yes ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " affirmative ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yep ", 1) Then Yes = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " yup ", 1) Then Yes = True
End Function
'direct No affirmation
Function No(OriginalSentence)
No = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " no ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " nope ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " it is not ", 1) Then No = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " negative ", 1) Then No = True
End Function
'if the user is not certain about the question then assume they are not certain.
Function Maybe(OriginalSentence)
Maybe = False
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't know ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't believe so ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i don't think so ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i'm not sure ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i never checked ", 1) Then Maybe = True
If InStr(1, " " & Lcase(HalBrain.AlphaNumericalOnly(OriginalSentence)) & " ", " i didn't check ", 1) Then Maybe = True
End Function
PS YOU REALLY NEED TO PUT YOUR CODES INSIDE A CODE BOX, IT'S THE BUTTON WITH THE "#" ON IT.
Title: Re: magic 8 ball plug in HELP!
Post by: systemshock on April 12, 2013, 08:43:39 am
THANK YOU ! I learnt  wat the  # button for  now man thanks..sort the code errors
.
Title: Re: magic 8 ball plug in HELP!
Post by: lightspeed on April 12, 2013, 09:27:33 am
this is a cool idea for fun , it's funny in a way , i had an idea something simlar but it was just to have a bunch of  random answers when asked certain questions. but your project looks interesting , i wish you luck on it !
Title: Re: magic 8 ball plug in HELP!
Post by: cload on April 12, 2013, 11:12:18 am
Hey lightspeed,
something like an Oracle?
In order to trigger the start you could say something like we must discuss it with the Oracle, or we must consult the Oracle.
Then the ultra Hal would say something like:
what is the question that you have for the great Oracle?

Sincerely, if nothing else it's a good start.
C load.
PS I thought it was pretty cool to, that's why I spent about an hour or so reprogramming it to get it to work.