Jump to content

Object Communication


WhyTheGreat
 Share

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

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

Recommended Posts

Hello, I have been dabbling in Object Communication in SL and it is not easy I now have come for help.

So I have one box with a number int of 0 and it changes when I click the box. I am trying to get another box to read that variable and display it in chat when it's clicked. My only issue is getting it to the other object. I don't want to use llEmail cause it's slower, so I think I'm stuck with httpresponse and httprequest. I just don't actually understand them. Could someone please help with a quick example POST and GET script by chance? Or any help pointing in the proper direction?

Thanks!

Link to comment
Share on other sites

I assume you mean that you are trying to send that message between objects on different regions. ( If they were on the same region, the task would be trivially simple -- just send the message by llRegionSay or llRegionSayTo. )  There is a pair of simple example scripts for object to object HTTP communication at http://wiki.secondlife.com/wiki/Object_to_object_HTTP_communication .  You'll want to adapt the RECEIVE code so that it doesn't reset the server URL every time you click on it and so that it doesn't send that URL to the GIVE script by llSay.  That's just a simple example, after all, designed as a local demo.

Link to comment
Share on other sites

The big problem everyone has with HTTP communication between LSL scripts is that the URLs are ephemeral, so the object acting as "server" gets a new address every time its sim restarts (and maybe other times), so there needs to be a way for its communication partner(s) to find it again. There is no elegant solution, only different kludge-arounds.

If all communicating objects will always be on land where an Experience can be allowed, Key-Value Pair updates are available across the grid almost instantaneously, although recipients need to poll for when an update is made.

Link to comment
Share on other sites

here is a snippet for GET... i think to use POST, you have to have a server on the web with php?

( I use this to set a channel for all  walkie talkies to use across 5-6 sims, the channel is stored on google docs)

 

integer chan;
key http_request_id;
string BASE_URL = "https://docs.google.com/document/d/******************************";
string SUFFIXE_URL = "/export?exportFormat=txt";

getChan()
{
string URL = BASE_URL + SUFFIXE_URL;
http_request_id = llHTTPRequest(URL ,
[HTTP_METHOD, "GET",
HTTP_MIMETYPE, "text/plain",
HTTP_BODY_MAXLENGTH,16384,
HTTP_PRAGMA_NO_CACHE,TRUE], "");
}


state_entry()
{ getChan();
}


http_response(key request_id, integer status, list metadata, string body)
{

if (request_id != http_request_id) return;// exit if unknown
if(status != 200) {llOwnerSay("Unable to get Radio channel");return;}
list decode = llParseString2List(body,[" "],[]);
string tmp = llList2String(decode,0);
chan = (integer)tmp;
llListen(chan,"",llGetOwner(),"");
llOwnerSay("\n Radio channel set to: " + (string)chan );
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3022 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...