|
Martin Mounier
Laguna Nude Beach
Join date: 16 Jul 2005
Posts: 24
|
03-10-2007 20:58
Hi there, QUESTION 1: is it possible to seek/read parameters from a "RL webserver"? REQUIREMENTS: I'd like to read a status like "on" or "off" from a URL like "www.domainname.com/status.txt". "status.txt" would contain one or more lines like : status=on or : status=off This status should be updated automatically every 2 mins. QUESTION 2: Who would like to assist me creating the scripts? I am not looking for freeware  thanks in advance, Martin  )
_____________________
Greets, Martin
_______________________________________________
|
|
Woopsy Dazy
Registered User
Join date: 12 Nov 2006
Posts: 173
|
03-11-2007 00:07
Here's a working sample. I did not comment code because it's so short. Make sure to put your ON/OFF state in the onoff.txt file. Do not write anything else but ON or OFF or you will have to change the code. Ask me and I'll help you if it's not good enough. float interval = 120.0; string url = "http://www.yoursite.com/onoff.txt"; key requestid; default { state_entry() { llSetTimerEvent(0.1); llSetText("", <0.0, 0.0, 0.0>, 0.0); } timer() { llSetTimerEvent(interval); llSetText("Connecting...", <1.0, 1.0, 0.0>, 1.0); requestid = llHTTPRequest(url, [HTTP_METHOD, "GET"], ""); } http_response(key request_id, integer status, list metadata, string body) { integer i; if (request_id == requestid) { if (body == "ON" || body == "OFF") { llSetText("Status is " + body, <0.0, 0.0, 1.0>, 1.0); } else { llSetText("Connection failed. Verify your website or url.", <1.0, 0.0, 0.0>, 1.0); } } } on_rez(integer start_param) { llResetScript(); } }
Enjoy! 
|
|
iblis Wombat
Registered User
Join date: 12 Feb 2006
Posts: 2
|
03-13-2007 19:07
From: Woopsy Dazy Here's a working sample. I did not comment code because it's so short. Make sure to put your ON/OFF state in the onoff.txt file. Do not write anything else but ON or OFF or you will have to change the code. Ask me and I'll help you if it's not good enough. float interval = 120.0; string url = "http://www.yoursite.com/onoff.txt"; key requestid; default { state_entry() { llSetTimerEvent(0.1); llSetText("", <0.0, 0.0, 0.0>, 0.0); } timer() { llSetTimerEvent(interval); llSetText("Connecting...", <1.0, 1.0, 0.0>, 1.0); requestid = llHTTPRequest(url, [HTTP_METHOD, "GET"], ""); } http_response(key request_id, integer status, list metadata, string body) { integer i; if (request_id == requestid) { if (body == "ON" || body == "OFF") { llSetText("Status is " + body, <0.0, 0.0, 1.0>, 1.0); } else { llSetText("Connection failed. Verify your website or url.", <1.0, 0.0, 0.0>, 1.0); } } } on_rez(integer start_param) { llResetScript(); } }
Enjoy!  quick question, woopsy: what license is the code you've posted under? i don't want to step on anyone's toes by using it as a basis for other things, and if you'd rather i not, i can respect that. 
|
|
Simil Miles
Creator
Join date: 1 Mar 2007
Posts: 300
|
03-13-2007 20:30
I guess you don't want to check an avatar's status or you would use llRequestAgentData So here's a simple working* example : * change the URL key status_check;
default { state_entry() { llSetTimerEvent(1.0); } timer() { status_check = llHTTPRequest("http://exampledn.com/status.txt", [HTTP_METHOD, "GET"], ""); llSetTimerEvent(120.0); } http_response(key request_id, integer status, list metadata, string body) { if (request_id == status_check) { if (body != "") { llOwnerSay(body); } else if (body == "") { llOwnerSay("No status"); } } } }
You can write anything in the text file and it will be fetched. If you want to have several things written but only a specific returned, you'll need to add a query to your URL and use PHP (or similar) on your site to send the corresponding content.
_____________________
UnConWTech @ Flo (144, 84, 224) http://unconwtech.free.fr
SL books http://astore.amazon.com/secondlife-sl-20/
Need a beta tester for quality assurance ? Need a translator for English, French, Spanish ?
|