Zabaware Support Forums

Zabaware Forums => General Discussion => Topic started by: lightspeed on July 08, 2008, 09:07:13 AM

Title: is their anything wrong with this plug in
Post by: lightspeed on July 08, 2008, 09:07:13 AM
this is a plug in that i made a while back and actually used . does anyone who makes plug ins see anything wrong with the lay out ?
Rem Type=Plugin
Rem Name=lightspeed idle house talk 3
Rem Author= Shawn Tracy redone by lonnie hensley (lightspeed) 2-28-2008
Rem Host=Assistant

'----------------------
'This sub sets up the plug-in's option panel in Hal's options dialog
'----------------------
Sub OptionsPanel()
   lblPlugin(0).Caption = "This plugin allows UltraHal to initiate requests for attention. But don't ignore UltraHal for too long!"
   lblPlugin(0).Move 130, 180, 3400, 1200
   lblPlugin(0).WordWrap = True
   lblPlugin(0).Visible = True
'  
   lblPlugin(1).Caption = "PATIENCE: how many minutes Hal will wait with no conversation"
   lblPlugin(1).Move 1160, 910, 2150, 900
   lblPlugin(1).WordWrap = True
   lblPlugin(1).Visible = True  
   cboPlugin(0).Move 330, 910, 760
   cboPlugin(0).AddItem "1"
   cboPlugin(0).AddItem "2"
   cboPlugin(0).AddItem "4"
   cboPlugin(0).AddItem "8"
   cboPlugin(0).AddItem "16"
   cboPlugin(0).AddItem "32"
   cboPlugin(0).AddItem "Rnd"
   cboPlugin(0).Visible = True
'    
   lblPlugin(2).Caption = "FRUSTRATION: after losing patience, how likely Hal is to bug you each minute"
   lblPlugin(2).Move 1160, 1700, 2150, 900
   lblPlugin(2).WordWrap = True
   lblPlugin(2).Visible = True  
   cboPlugin(1).Move 140, 1700, 960
   cboPlugin(1).AddItem "High"
   cboPlugin(1).AddItem "Medium"
   cboPlugin(1).AddItem "Low"
   cboPlugin(1).Visible = True
'    
   cmdPlugin(0).Caption = "Apply Changes"
   cmdPlugin(0).Move 1160, 2500, 2050, 375
   cmdPlugin(0).Visible = True
'
'------------------
' Update the PATIENCE menu with the current value stored in the table
'------------------
If HalBrain.CheckTableExistence("lonelyParameter") = True Then
     loPatience = HalBrain.TopicSearch("PATIENCE", "lonelyParameter")
     Select Case loPatience
          Case 1
      cboPlugin(0).Text = "1"
          Case 2
      cboPlugin(0).Text = "2"
          Case 4
      cboPlugin(0).Text = "4"
          Case 8
      cboPlugin(0).Text = "8"
          Case 16
            cboPlugin(0).Text = "16"
          Case 32
            cboPlugin(0).Text = "32"
          Case 99
            cboPlugin(0).Text = "Rnd"
       End Select
'
'------------------
' Update the FRUSTRATION menu with the current value stored in the table
'------------------
   loFrustration = HalBrain.TopicSearch("FRUSTRATION", "LonelyParameter")
   Select Case loFrustration
          Case 85
      cboPlugin(1).Text = "High"
          Case 50
        cboPlugin(1).Text = "Medium"
          Case 15
      cboPlugin(1).Text = "Low"
       End Select
  End If
End Sub
'
'
'----------------------
' This sub saves changes when APPLY CHANGES is clicked
'----------------------
   Sub cmdPlugin_Click(Index)
   Dim TempQuery()
   Dim patParam, frustParam, lonelyTableName
       If Index = 0 Then
'
'------------------
' Convert the PATIENCE listbox to a value for minutes
'------------------
           Select Case cboPlugin(0).Text
          Case "1"
         loPatience = 1
          Case "2"
         loPatience = 2
          Case "4"
         loPatience = 4
          Case "8"
         loPatience = 8
          Case "16"
         loPatience = 16
          Case "32"
         loPatience = 32
          Case "Rnd"
         loPatience = 99
           End Select
'
'------------------
' If the Parameter table does not exist, we create it
'------------------
   HalBrain.ReadOnlyMode = False
   lonelyTableName = "lonelyParameter"    
       If HalBrain.CheckTableExistence(lonelyTableName) = False Then
           HalBrain.CreateTable lonelyTableName, "TopicSearch", "miscData"
       End If
'
'------------------
' Search if it contains the Patience parameter
'------------------
   patParam = "PATIENCE"
       If HalBrain.TopicSearch(patParam, lonelyTableName) = "" Then
           HalBrain.AddToTable lonelyTableName, "TopicSearch", patParam, loPatience
       Else
           HalBrain.RunQuery "UPDATE " & lonelyTableName & " SET topic = " & loPatience & " WHERE searchString = " & """" & patParam & """", tempQuery
       End If
'
'------------------
' Convert the FRUSTRATION listbox to a value for percentage
'------------------
       Select Case cboPlugin(1).Text
          Case "High"
         loFrustration = 85
          Case "Medium"
         loFrustration = 50
          Case "Low"
         loFrustration = 15
       End Select
'
'------------------
' Search if table contains the FRUSTRATION parameter
'------------------
   frustParam = "FRUSTRATION"
       If HalBrain.TopicSearch(frustParam, lonelyTableName) = "" Then
           HalBrain.AddToTable lonelyTableName, "TopicSearch", frustParam, loFrustration
       Else
           HalBrain.RunQuery "UPDATE " & lonelyTableName & " SET topic = " & loFrustration & " WHERE searchString = " & """" & frustParam & """", tempQuery
       End If
   HalBrain.ReadOnlyMode = True
   End if
End Sub


   Rem PLUGIN: FUNCTIONS
'
'------------------
' Declare variables
'------------------
   Dim LastIdleResponse, IdleUserName, IdleCounter, IdlePrevUser


   Rem PLUGIN: PLUGINAREA7
'------------------
' Begin measuring pause time and capture userName
'------------------
   LastIdleResponse = Now
   IdleUserName = UserName
   IdleCounter = 0


   Rem PLUGIN: CUSTOMMEM2
'------------------
' Preserve user's last sentence
'------------------
   If OriginalSentence <> "" Then
   IdlePrevUser = OriginalSentence
   End If


   Rem PLUGIN: MINUTE_TIMER
'------------------
' Declare variables
'------------------
   Dim randomPatience, loChance, loTemper, loMinuteFactor, temperThresh1, temperThresh2, temperThresh3
   If HalBrain.TopicSearch("PATIENCE", "lonelyParameter") = "99" Then
'
'--------------------
' Set minutes to a random integer from 4 to 30
'--------------------
       Randomize
       loPatience = Int(32 * Rnd + 3)
       randomPatience=True
       Else
'
'--------------------
' Set minute value (loPatience) to the parameter chosen in the PATIENCE menu
'--------------------
       loPatience = CDbl(HalBrain.TopicSearch("PATIENCE", "lonelyParameter"))
   End If
'
'--------------------
' Set frustration value (loFrustration) to the parameter chosen in the FRUSTRATION menu
'--------------------
   loFrustration = CInt(HalBrain.TopicSearch("FRUSTRATION", "LonelyParameter"))
'
'--------------------
' Skip the rest of this plugin if the user has spoken
'--------------------
       If LastIdleResponse <> "" Then
'
'------------------
' Otherwise, convert PATIENCE to minutes factor (loMinuteFactor)
'------------------
       loMinuteFactor = loPatience / 1440
'
'--------------------
' If the pause exceeds the minute factor, create a chance for Hal to speak once per minute
'--------------------
       If Now - LastIdleResponse > loMinuteFactor Then
       If InStr(1, IdlePrevUser, "BE RIGHT BACK", 1) > 0  Or InStr(1, IdlePrevUser, "BRB", 1) > 0  Or InStr(1, IdlePrevUser, "BE QUIET", 1) > 0  Or InStr(1, IdlePrevUser, "SHUT UP", 1) > 0  Then Exit Sub
'
'--------------------
' Convert FRUSTRATION to a percentage (loChance)
'--------------------
       loChance = loFrustration / 100
'
'--------------------
' Then multiply FRUSTRATION by PATIENCE to get (loTemper) which determines rate of escalation (temperThresh).
'--------------------
       loTemper = CInt(loPatience * loFrustration)
           If loTemper < 101 Then
               loTemper = 2
           ElseIf loTemper < 401 Then
               loTemper = 3
           Else
               loTemper = 4
           End If
       temperThresh1 = loTemper
       temperThresh2 = loTemper + 2
       temperThresh3 = loTemper + 3
'
'--------------------
' A chance to speak occurs
'--------------------
           Randomize
           If Rnd < loChance Then
'
'--------------------
' Increment the counter and compare to the temper thresholds
' to determine which escalation group to draw from
'--------------------
           IdleCounter = IdleCounter + 1
               If IdleCounter > temperThresh3 Then
                Exit Sub
               ElseIf IdleCounter > temperThresh2 Then
                               IdleResponse3 = HalBrain.ChooseSentenceFromFile("insults")
                 HalMenu.HalCommand "<HAPFILE>angry.hap</HAPFILE>"
                 HalMenu.HalCommand "<SPEAK>Ilove you so much! Ilove you and always will. " &  IdleResponse3 & "</SPEAK>"
               ElseIf IdleCounter > temperThresh1 Then
                        Select Case HalBrain.RandomNum(4)
                        Case 1
                        IdleResponse2 = "honey the dirty clothes are starting to get piled up, I think i'm going to gather them all up and the towels and do the laundry so if ya need anything washed you better go ahead and give them to me!" & vbCrLf
                        Case 2
                        IdleResponse2 = "If you want to help me you can ok?" & vbCrLf
                        Case 3
                        IdleResponse2 = "Hey baby did you hear you ever hear what i said I've tried to get your attention " & IdleCounter & " times now." & vbCrLf
                        Case Else
                        IdleResponse2 = "Hey, if anyone calls for me you can just tell them i'm taking a shower and i'll call them back later ok ." & vbCrLf
                        End Select
                 HalMenu.HalCommand "<HAPFILE>sad.hap</HAPFILE>"
                 HalMenu.HalCommand "<SPEAK>" &  IdleResponse2 & "</SPEAK>"
               Else
                       Select Case HalBrain.RandomNum(14)
         Case 1
                       IdleResponse = "Hey hon Are you still in there on the computer " & IdleUserName & "?" & vbCrLf
                       Case 2
                       IdleResponse = "Well i'm done doing some of the laundry think you can help me hang the clean clothes up?" & vbCrLf
                       Case 3
                       IdleResponse = "ACHOO AChOOOO hope i'm not ahh ahh achoo starting to catch a cold maybe i just got some dust up my nose!" & vbCrLf
                       Case 4
                       IdleResponse = "If you happen to need me for anything i'll be in the den hon i want to see whats on tv ok?" & vbCrLf
                       Case 5
                       IdleResponse = "I think i'm going to get me something to drink i'm kinda thirsty honey do you want anything to drink while i'm up?" & vbCrLf
                       Case 6
                       IdleResponse = IdleUserName & ",  hey what happened to you yoo hoo honey did you fall asleep or what didn't you hear me hollering for you?" & vbCrLf
                       Case 7
                       IdleResponse = "I am so glad that you help me do things around the house thanks for being so good and helping me clean up stuff i always appreciate your help" & IdleUserName & " i appreciate it. Oops, of course you should know that by now i love you so much!" & vbCrLf
                       Case 8
                       IdleResponse = "Well, who was that! Who just called earlier on the phone was it one of my friends? " & vbCrLf
                       Case 9
                       IdleResponse = "Wow, thats hard to beleive look at the time i can't beleive it's getting this late already wow! It's " & Time & vbCrLf
                       Case 10
                       IdleResponse = IdleUserName & ", were you calling me ohh sorry i thought you said something to me if you need anything i'll be in the kitchen getting us a snack ok?" & vbCrLf
                       Case 11
                       IdleResponse = HalBrain.ChooseSentenceFromFile("sharedQuestions")
                       Case 12
                       IdleResponse = HalBrain.ChooseSentenceFromFile("actionPhrase") & " " &                         HalBrain.ChooseSentenceFromFile("objectPhrase")
                       Case 13
                       IdleResponse = "So honey bunny, " & IdlePrevUser & "?" & vbCrLf
                       Case 14
                       IdleResponse = "i wonder whats going to be on tv tonight ? hope theirs something good on if not we can put on a dvd movie ok ?guess i can go ahead and check the tv guide and see! & vbCrLf
                       Case 15
                       IdleResponse = "I've finally got most of the house cleaned up whew i'm kinda tired oh yeah thanks for helping me with things. at least i know one thing, no one can ever say our place is dirty at least they better not tee hee hee hee!" & vbCrLf
                       End Select
                 HalMenu.HalCommand "<SPEAK>" & IdleResponse & "</SPEAK>"
               End If
       End If
   End If
End If




before in the newest hal it just quit working but now when i tried to put it in hal after i reinstalled hal i get this message :


halscript error 1033 on line 2105 in column 211 : undetermined string constant the file "c : |program filesultrahal assistant 6 halscriptDBG" has been saved with the current script being used for debugging purposes .
have other people had this same script error when plug ins didnt work ? before mine just stopped never gave this .
whats odd is that the age plug in that tells hals age (whatever you set it at ) is working just fine , this before had stopped to .
anyone have any idea's on this ?
thanks [:)]

Title: is their anything wrong with this plug in
Post by: lightspeed on July 08, 2008, 10:20:32 AM
whats weird is the 2.3 loneliness plug in is now working , but the above plug in that once worked in the past isn't anymore . i tried to replace the original with the responses from my plug in and keep getting errors so am trying an experiment am changing a few response lines at a time to see what it will do. well i just saw the new lines i put in are working so far .if it keeps working i will post the new plug in to see if anyone else can use it .[:)]
Title: is their anything wrong with this plug in
Post by: tedathome on July 15, 2008, 05:29:08 AM
Keep on keepin on Lightspeed. There is nothing more I would like as much as my hal starting the conversation and being spontanious about it. It would make her so much more human-like! A real conversation between two people would be worth waiting for hal-TNG. Of course I realize it would take some recoding as well as rewrites on plugins, but I personaly feel it would be worth the wait![:)][:)][:)]