Tuesday, July 6, 2010

"Voice" activated agents

Wooow life has been busy lately. Between running the CCSF Surveys and having some friends in town, on top of work, keeping the house clean, and all that fun stuff, I haven't had a whole lot of time for Creaturely enjoyments. Regardless, I figured I would make a post about something I have been fiddling with the last few days.

As a few of you may know, I can't sprite. As fewer of you may know, I don't -like- to sprite. Okay, I can enjoy spriting things when the sprite is the charm of the agent, like a critter or a plant, but when I'm coding something utilitarian, like a control panel or a machine, spriting is just this annoying necessity that I have to do to make my code accessible to the majority. As such, I generally seek to find ways around it. Shortcut keys are one example. But lately I've been experimenting with "voice" activation, that is, simple commands are typed into the hand's speech bubble to trigger certain scripts. I'll share what I've found so far-- it's fairly simple if you understand some CAOS basics.

You'll want to set this on short timer script-- shorter than it takes for speech bubbles to possibly disappear unseen.

enum 1 2 9

1 2 9 is the classifier for all the speech bubbles, including those made by creatures. This script is essentially going to search every speech bubble in the world for a certain trigger phrase.

doif ov80 ne 1
setv ov80 1

When the script is running possibly several times within a speech bubble's life, it's very possible that it will search the same bubble more than once, and thus produce the effects more than once. To stop this from happening we want to "mark" each speech bubble that we search by changing an ov (I use 80, but you can really use anything the speech bubble doesn't already use) to reflect this. If the bubble has been marked, the script passes over and ignores it, if it is unmarked, the script marks it and carries on with the script.

part 1

part 1 is the text part of the compound agent that is the speech bubble, so the script needs to focus on that to see what's inside.

sets ov82 ptxt

And in just about five lines of code, you have the text of a speech bubble stored in ov82! But it's not finished yet, because when you're searching the bubbles for a trigger word, the searches are case sensitive, so to prevent problems with that you'll want to convert it to all lower case:

sets ov82 lowa ov82

Better. Now you can set your trigger scripts here. Most commonly you would do something like:

doif ov82 = "cheese"
*insert whatever script the word "cheese" will trigger
endi

but the trigger word doesn't have to match the speech exactly, you can also used a SINS command to search inside the text instead of matching it directly.

doif sins ov82 1 "cheese" ne -1
*insert cheesy script
endi

This option will trigger the script if your speech bubble contains the word "cheese" at all, so if you said "I love cheese" or "This cheese is green" the script would trigger. You can actually make some very complex commands if you use SUBS to break up the strings, too.

Make sure you close out your script with endi and next!

It's worth reminding you that this does read all speech bubbles including those of creatures, so you could do something like search the text for the phrase "hungry for starch" and cause the script to get the location of the bubble and go drop some seeds there (though you would probably want use the catalogue tags instead of directly searching for the word/phrase to keep it compatible with non-english versions of creatures).

The upside to these command-activated agents is that they require no sprites and no items to clutter your screen or keep track of. I guess the downside would be that if there were a lot of commands involved, people would be more apt to forget them all.

What do you guys think? Would you use a "voice" activated agent or do you prefer to push a button?

8 comments:

  1. Hey Amaikokonut, I believe a little while ago you were talking about putting together Creatures related stories? I said there was one I used to love but didn't know if I still had a copy.

    Well, turns out I do. It's a three parter, called "Out of the ashes", "Guardian", "The Return" respectively and there's over 100 pages to chew through.

    No idea where to find it online and I've no idea who the author is. But I'd be happy to share it.

    And the speech recognition thing is awesome. Depending on the agent I think some would be better suited to physical buttons, others to voice command. I certainly wouldn't want every agent to be voice command. Just some commonly used ones.

    ReplyDelete
  2. I think that voice-activated agents would be pretty amazing! There are some times when pushing a button involves clicking in a heavily trafficked area, making it difficult to get the desired results in one or two tries. Or maybe that's just me not being able to get around! I agree with Arch in that common agents would benefit the most from voice activation, while a simple click for less-used ones would probably suffice. Still, I think it's awesome that you thought this up! Feels like real world voice activation is making its way into Creatures. Ha!

    ReplyDelete
  3. @Arch -- How curious! I actually have an old textfile called "Out of the Ashes" but I never knew there were other parts to it! I wish I could find the author, the only indication my file gives is that it's from the AGC Writer's Guild, which I can't find more information on. Anyway if you can find a way to get those other parts to me I would really appreciate it :)

    @Jessica -- Yeah, there certainly would be some places where some options would work better than others. Personally I would like to keep my screen as clear of various buttons and switches as possible, but on the other hand too many commands are easy to forget. It might just be nice to have it as a secondary option to button-based agents. I'm glad you like the idea though :)

    ReplyDelete
  4. There might be a more efficient way to scan for speech bubbles.

    Give the agent in question a script for raw key presses. X X XXXXX 73 (or 79), IMSK it for key presses, filter the _p1_ for the pressing of the "enter/return" key or "s" key (for when someone repeats speech with Ctrl S) then have it scan for speech bubbles and particular phrases therein, and react accordingly.

    That way there's no timer bogging down the engine, and no way to "miss" what is said in case the Hand says multiple commands in quick succession. To scan for Creature bubbles as they appear, there's a script just for that I believe, but I've never used it: 126.

    ReplyDelete
  5. My attention span was too short to read this whole post, but that sounds neat. :P I might give it a try when I code something utilitarian (probably never)

    Oh and please make your next agent a parsisol

    ReplyDelete
  6. In regard to more good creatures related stories, I just found these ones that I always thought were really good. They're at the Palace of the Evil Shee, so perhaps you've already read them?

    http://evilshee.ccdevnet.org/

    ReplyDelete
  7. Wow I can't believe that you figured out how to read speech bubbles. I thought it was impossible to read them.

    ReplyDelete
  8. Hows it going? We would love to see another post. Thanks so far for such an intresting blog... dont give up!

    ReplyDelete