Jump to content

Torisu10

Resident
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Torisu10

  1. 1 hour ago, Wulfie Reanimator said:

    A script can register a listen-event on (one or more) chat channels with llListen.

    If you want the script to only trigger the listen event on exactly the message "awesome, thanks!" you can register a listener like so:

    
    llListen(PUBLIC_CHANNEL, "", "", "awesome, thanks!");

    The above code will make the script

    • listen to anyone (no name or key constraint)
    • on the public chat channel (0)
    • saying the message "awesome, thanks!"
      • It will not accept "awesome thanks"
      • It will not accept "Awesome, thanks!"
      • It won't even accept "That's awesome, thanks!"
      • The message must match exactly.

    Instead, what you probably want is:

    
    llListen(PUBLIC_CHANNEL, "", "", "");

    Now, the above code will make the script

    • listen to anyone
    • on the public channel
    • saying any message

    So, a listen event will trigger for every message. But that's okay. You can then start parsing the chat message to see if your wanted message is in there. For example:

    
    listen(integer channel, string name, key id, string message)
    {
        // channel: WHERE the message was heard
        // name:    the avatar or object's NAME
        // id:      the avatar or object's KEY (uuid)
        // message: the actual TEXT content
    
        // Make all the text lowercase, so the input-case no longer matters.
        message = llToLower(message);
    
        // Search for an exact "awesome, thanks" from the message.
        // The index will be -1 if it wasn't found anywhere.
        integer index = llSubStringIndex(message, "awesome, thanks");
    
        if (index != -1)
        {
            llOwnerSay(name + " said it!");
        }
    }

    You can complicate it further by searching for the words "awesome" and "thanks" separately, and even making sure that the word "awesome" comes before "thanks." Make sure to read the wiki often. It really is your friend, even though some pages can be a bit much to take in.

    http://wiki.secondlife.com/wiki/llToLower
    http://wiki.secondlife.com/wiki/llSubStringIndex
    http://wiki.secondlife.com/wiki/llOwnerSay
    http://wiki.secondlife.com/wiki/llSay

    P.S. You can of course write 0 instead of PUBLIC_CHANNEL. I used that constant just for clarity.

    what if I want to detect a message coming from the same object or is this possible

  2. For example, if the public chat has a last recorded message saying "hello world" could a script detect this somehow to be used in scripting?

    A more clear example.. if the chat is like this:

    1: hey how are you

    2: im great wbu?

    3: awesome, thanks!

    (event in script will then trigger)

    --

    I want to make a script that will constantly detect the last stated message on the public channel until it hits the correct string that will trigger an event in the script. For the sake of the example, lets assume the string its parsing for in each last stated message is "awesome, thanks!". Once the last stated message is "awesome, thanks!" an event will trigger within the script...

    Is this actually possible? thanks

  3. I can use if statements but for some reason i cant use else if or else statements at all in my scripts. I've tried so many different ways to solve this. here is my sample code.

     if (message == "Add 1 to green" && count == 0)
                green_count += 1;
                count += 1;
                llSetText("Green: " +(string)green_count,<1.0,1.0,1.0>,1.0);
     else
                count -= 1;

     

    I'm constantly getting an error on the else command line.

×
×
  • Create New...