Author Topic: Please help me find the error  (Read 5067 times)

apollon

  • Newbie
  • *
  • Posts: 12
    • View Profile
Please help me find the error
« on: April 30, 2009, 07:31:24 pm »
I'm trying to get Hal to change his background image in response to certain keywords. Please understand that I've already searched the forum, and I did find some relevant threads, but they weren't of any help because I either don't understand what's being said, or the proposed solutions simply don't work. (However, I did try to copy quite a few of their ideas)

Here's what I did:
I created a file named change.hap. I put that file into the characters folder, where the other .hap files are.
The .hap file does work when I drag it onto a separate haptar (I mean a .htr file started and running separately from Hal). When I drop the file onto the haptar, the background image changes to the one I specified.
I opened the main brain .uhp and added the following lines after the very last line:

Code: [Select]
File = ""
UserSentence = LCase(UserSentence)

If InStr(UserSentence, "change background") <> 0 Then
File = "change.hap"
End If

If file <> "" Then
HalCommands = "<HAPFILE>" & File & "</HAPFILE>"
BlockSave = True
GetResponseBlock = True
End If

However, the thing doesn't work when I enter the key phrase. There's no error message, Hal is just ignoring it.

I respectfully ask that you do not direct me to any plugins that already do this sort of thing. I would very much prefer to learn how to do it myself, rather than messing with plugins. :-)
« Last Edit: April 30, 2009, 07:34:18 pm by apollon »
 

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Please help me find the error
« Reply #1 on: April 30, 2009, 11:02:46 pm »
Hey apollon, see if this plugin does what you want... if not you can modify it to suit your needs.[:)]




Download Attachment: HapSwap.uhp
2.58 KB
« Last Edit: April 30, 2009, 11:40:24 pm by snowman »
Live long and prosper or die trying.

apollon

  • Newbie
  • *
  • Posts: 12
    • View Profile
Please help me find the error
« Reply #2 on: May 01, 2009, 12:19:45 am »
Hello Snowman, thanks for your reply![:)]
I looked at your script, and it's very similar to the one I'm trying to make work. Different variables, but same syntax. Unfortunately, it, too, doesn't work. I tried to append it to the main brain .uhp, rather than having it as a separate plugin. Is that even possible, or am I just being foolish?
 

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Please help me find the error
« Reply #3 on: May 01, 2009, 01:16:11 am »
This plugin, as well as all plugins, are essentially appended to the main brain when the plugin is selected in the options panel.

The brain has plugin areas which are located at various locations within the main hal brain. These areas are labeled: PLUGINAREA1, PLUGINAREA2, PLUGINAREA3, PLUGINAREA4, PLUGINAREA5, PLUGINAREA6, and PLUGINAREA7. This HapSwap.uhp plugin is loaded in PLUGINAREA6.

It's located in PLUGINAREA6 because of potential conflicts with other Hal brain functions. This has to be considered when writing any plugin.

If you are determined to write this plugin into Hal's brain then I suggest placing it in the PLUGINAREA6 (or in the general vicinity). It might just work like that. Of course, I've never done that before. I don't like to play around with the main script if I don't need to. The plugins allow a person to select or deselect at the users whim. And I think they are easier to modify, distribute, and keep track of than a large and potentially confusing situation in which you could potentially loose track of your brain modifications....

By the way, that was a great idea you had. It made me look into the Hal Commands alittle deeper. Thanks.
Live long and prosper or die trying.

apollon

  • Newbie
  • *
  • Posts: 12
    • View Profile
Please help me find the error
« Reply #4 on: May 02, 2009, 10:12:16 am »
Ahoy, Snowman! I finally figured it out. There was nothing wrong with the script. Both your version and mine work just fine. I just had put them into a bad location inside the main script, and so it kept being overruled by another part of the brain. [:I]
Thanks for pointing me in the right direction! [:)]
 

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Please help me find the error
« Reply #5 on: May 02, 2009, 05:17:57 pm »

I'm glad to hear that apollon...

keep up the good work [:)]
Live long and prosper or die trying.

apollon

  • Newbie
  • *
  • Posts: 12
    • View Profile
Please help me find the error
« Reply #6 on: May 04, 2009, 06:44:38 pm »
Going one step further:
Would it be possible to make the background change not based on what _I_ say, but based on what _Hal_ says? Like, for example, if were to I ask: "What is your favourite colour?", and Hal would respond "Blue!" and trigger a blue background to appear.
 

snowman

  • Hero Member
  • *****
  • Posts: 956
  • Ai + Feelings + Supercompter = End of World
    • View Profile
    • http://www.MinervaAi.com
Please help me find the error
« Reply #7 on: May 05, 2009, 02:41:14 am »
Off hand I don't know of any technique of internally capturing Hals response. If that could be done that would be truly awesome.

If UltraHal = "whatever" then ..... I think I've seen something like this in a Hal Brain once...

However, you can make Hal respond to any given question with not only a verbal GetResponse but also your color response.

Like:

If Instr(1,OriginalSentence,"What is you favorite color?", -1, 1) > 0 Then...
GetResponse = "My favorite color is blue."
HalCommands = "<HAPBACK>" & "Blue.htr" & "</HAPBACK>"

End If

There might be another way of getting Hal to respond on it's own but I'm sure that would involve some on my Frankenstein methods....

Someone else might know for sure.... [:)]
« Last Edit: May 05, 2009, 02:48:33 am by snowman »
Live long and prosper or die trying.