Jump to content

Trigger sound from another sim


Isobeast
 Share

You are about to reply to a thread that has been inactive for 1079 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi! Is there a way to trigger the sound of the hud attached on an avatar when another avatar colliding with an object in another sim? I kind of managed to use llRegionSay and listen event in the hud for simwide, but can I do it gridwide? For example somehow convert llInstantMessage to a trigger?

Edited by Isobeast
Link to comment
Share on other sites

54 minutes ago, Wulfie Reanimator said:

llRequestURL and then send llHTTPRequest to that.

You need a way for the sender to know the receiver's URL, though. Depending on what you're doing, that might become very tricky.

Thank you! I just need to play the sound snippet when someone collides an object in another sim. I touched the url topic a few times, looked through the examples from the wiki and did not understand anything ... XD

And the option with the llInstantMessage does not make sense? At least in the most primitive way?

Link to comment
Share on other sites

FWIW you can also use llEmail() for long-distance communication if the volume of messages is low.

Scripts cannot hear llInstantMessages unfortunately. Only Real-live people and specialized bots using weird viewers can read those messages.

 

Edit: for a HUD, you'll still run into problems, as attachments probably don't have very consistent UUIDs. Do your own tests to confirm though. Perhaps you could use a Key-Value Pair (only available to premium Residents :/) to keep the UUID and/or URL updated.

Edited by Quistessa
  • Thanks 1
Link to comment
Share on other sites

1 hour ago, Isobeast said:

Thank you! I just need to play the sound snippet when someone collides an object in another sim. I touched the url topic a few times, looked through the examples from the wiki and did not understand anything ... XD

This script goes in the object that wants to play sounds:

key url_request;

default
{
    state_entry()
    {
        // When script starts, try to get a usable URL.
        url_request = llRequestURL();
    }

    http_request(key id, string method, string body)
    {
        if (id == url_request && method == URL_REQUEST_GRANTED)
        {
            // Our request for a usable URL was granted.
            // Other scripts can send requests to this URL.
            // If requests are made, http_request event will be triggered again.
            llOwnerSay("Listening at: " + body);
        }
        else
        {
            // Assume somebody made a request.
            llOwnerSay(body);

            // if (body == "trigger sound")
            //     llTriggerSound(sound, 1);
        }
    }
}

And this goes in the colliding object:

default
{
    // collision_start(integer n)
    touch_start(integer n)
    {
        // This URL is an example. The script needs some way to discover this.
        string url = "http://simhost-08e4294b960b4fa2c.agni.secondlife.io:12046/cap/f986cc2d-2f89-780b-c3d4-496c7ca6599e";
        llHTTPRequest(url, [HTTP_METHOD, "POST"], "trigger sound");
        llOwnerSay("Sent request to URL");
    }
}

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

33 minutes ago, Wulfie Reanimator said:

This script goes in the object that wants to play sounds:


key url_request;

default
{
    state_entry()
    {
        // When script starts, try to get a usable URL.
        url_request = llRequestURL();
    }

    http_request(key id, string method, string body)
    {
        if (id == url_request && method == URL_REQUEST_GRANTED)
        {
            // Our request for a usable URL was granted.
            // Other scripts can send requests to this URL.
            // If requests are made, http_request event will be triggered again.
            llOwnerSay("Listening at: " + body);
        }
        else
        {
            // Assume somebody made a request.
            llOwnerSay(body);

            // if (body == "trigger sound")
            //     llTriggerSound(sound, 1);
        }
    }
}

And this goes in the colliding object:


default
{
    // collision_start(integer n)
    touch_start(integer n)
    {
        // This URL is an example. The script needs some way to discover this.
        string url = "http://simhost-08e4294b960b4fa2c.agni.secondlife.io:12046/cap/f986cc2d-2f89-780b-c3d4-496c7ca6599e";
        llHTTPRequest(url, [HTTP_METHOD, "POST"], "trigger sound");
        llOwnerSay("Sent request to URL");
    }
}

 

Thank you!!! I do not deserve this! This is very kind of you! :3

But what is it here  string url = "http://simhost-08e4294b960b4fa2c... here and where to get it? I tried slurl but it seems something different?

Link to comment
Share on other sites

2 hours ago, Quistessa said:

FWIW you can also use llEmail() for long-distance communication if the volume of messages is low.

Scripts cannot hear llInstantMessages unfortunately. Only Real-live people and specialized bots using weird viewers can read those messages.

 

Edit: for a HUD, you'll still run into problems, as attachments probably don't have very consistent UUIDs. Do your own tests to confirm though. Perhaps you could use a Key-Value Pair (only available to premium Residents :/) to keep the UUID and/or URL updated.

Thank you! Unfortunately I don't have a premium, trying Wulfie's scripts, for tests using llSay. :)

Link to comment
Share on other sites

You can use either the http method or email without premium, but you'll probably have problems either way if the object that plays the sound is something you rez and de-rez often (like for example a worn object).  I've not played with http requests much, maybe the requested URLs are stable? I would just recommend doing a lot of tests before trusting it in anything you might distribute widely.

  • Thanks 1
Link to comment
Share on other sites

8 minutes ago, Quistessa said:

You can use either the http method or email without premium, but you'll probably have problems either way if the object that plays the sound is something you rez and de-rez often (like for example a worn object).  I've not played with http requests much, maybe the requested URLs are stable? I would just recommend doing a lot of tests before trusting it in anything you might distribute widely.

Thanks, but where can I get this URL and why is it unstable?

Link to comment
Share on other sites

29 minutes ago, Isobeast said:

But what is it here  string url = "http://simhost-08e4294b960b4fa2c... here and where to get it? I tried slurl but it seems something different?

Try the scripts I posted and you'll see.

16 minutes ago, Quistessa said:

I've not played with http requests much, maybe the requested URLs are stable?

Nope, URLs are released when the object derezzes. URLs are handled by the sim and there is a hard limit on how many URLs will be granted across all scripts in the region, so it would not make sense to "keep URLs alive" when the object goes away.

Edited by Wulfie Reanimator
  • Like 2
Link to comment
Share on other sites

17 minutes ago, Wulfie Reanimator said:

Try the scripts I posted and you'll see.

You could be nice and say that it's what script #1 llOwnerSays to you, which seems to me kind of evident from the code, but I did my due diligence and confirmed it in-world.

17 minutes ago, Wulfie Reanimator said:

there is a hard limit on how many URLs will be granted across all scripts in the region.

IIRC that limit is 64.

Also, a bit off-topic, but do you have/know where one could find a reference script that does the correct HTTP things when interacting with a standard web-browser? As a non-web-developer I have no idea what different methods (get,put post...) are supposed to be used for, or what user-action would cause a browser to send those messages.

Also, is there any good reason to use requestURL over requestSecureURL?

Edited by Quistessa
  • Thanks 1
Link to comment
Share on other sites

26 minutes ago, Wulfie Reanimator said:

Try the scripts I posted and you'll see.

Nope, URLs are released when the object derezzes. URLs are handled by the sim and there is a hard limit on how many URLs will be granted across all scripts in the region, so it would not make sense to "keep URLs alive" when the object goes away.

I honestly did :3 

Created two objects and placed scripts in them, after the line llOwnerSay(body) added llSay for tests, but when I click, only a message appears: "Sent request to URL", I figured this was happening because the script contains a sample url and I need to get mine somewhere in order to work?
And did I understand correctly that I need to uncomment the line?

// if (body == "trigger sound")
 

Link to comment
Share on other sites

3 minutes ago, Isobeast said:

I need to get mine somewhere in order to work

Yes, object #1 (with the first script) should say something like

Quote

then you copy paste http://... into script number 2 and use that in another object.

  • Thanks 1
Link to comment
Share on other sites

4 minutes ago, Quistessa said:

Yes, object #1 (with the first script) should say something like

then you copy paste http://... into script number 2 and use that in another object.

Thank you very much, now everything is clear! :)

Link to comment
Share on other sites

1 hour ago, Quistessa said:

Also, a bit off-topic, but do you have/know where one could find a reference script that does the correct HTTP things when interacting with a standard web-browser? As a non-web-developer I have no idea what different methods (get,put post...) are supposed to be used for, or what user-action would cause a browser to send those messages.

I'm a little fuzzy on the details myself, in the sense that I don't do web stuff regularly enough to give very specific answers off the top of my head.

Mozilla for example has a pretty clear reference for the purpose of different HTTP methods:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods (Click the names for more in-depth explanations.)

Which one you need depends entirely on the web server you're trying to contact. For communicating with LSL scripts, POST works similarly enough to more traditional LSL-functionality. (Since POST basically means "send message.")

1 hour ago, Quistessa said:

Also, is there any good reason to use requestURL over requestSecureURL?

Same difference as HTTP vs HTTPS; that's the best answer I can give. 🤷‍♀️

  • Like 2
Link to comment
Share on other sites

Having to copy and paste the URL is more manual labor than most uses really justify. What's needed is a registry at a stable address that holds the current ephemeral URL. There are (or were?) some external web services that performed that function, but one might not want to go outside SL just to get a URL. What we did for years (before there was Experience KVP store) was to llEmail to a permanent, rezzed-in-world object to register the new URLs and to query for them. Anything requiring high availability, though, would need multiple of these Email registry hubs, on different regions to have reasonable expectation one would be present during rolling restarts, etc. And llEmail had an annoying habit of getting wedged once or twice a year, requiring some special intervention to restore it without changing the hub's UUID and hence its email address. (I wonder if AWS might have magically cured that bug.)

Even longer ago, before LSL even knew HTTP communications, we'd use llEmail directly, but to communicate between transitory objects (with changing UUIDs and email addresses) we'd still need permanent hub objects to act either as address registries or as email relays.

So KVP is the tidiest in-world-only way to do grid-wide communications, but only if you have control of (land-scope) Experiences on any land where messages are either sent or received.

Incidentally, it's not necessary to be Premium to use KVP, and to develop a KVP application you only need a Premium friend who trusts you enough to add you as a Contributor to their Experience or is willing to compile your source code for you. But the land-scope limitation rules out many applications where either sender or recipient might be out-and-about, not on Experience-enabled land.

Link to comment
Share on other sites

23 minutes ago, Qie Niangao said:

Having to copy and paste the URL is more manual labor than most uses really justify. What's needed is a registry at a stable address that holds the current ephemeral URL.

So far we have no context at all for what these objects are doing (or for what purpose). That's why I gave the most universally applicable example instead of over-engineering it too quickly.

For example, if the sound source (rezzer?)'s lifetime is greater than the collider, it should be no issue to programmatically communicate the correct URL to it before anything crosses a sim boundary and just refer to it that way.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1079 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...