touch.lsl 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. string touchURL = "[Insert your full URL here]/touch/";
  2. key http_request_id;
  3. default
  4. {
  5. state_entry()
  6. {
  7. llSetText("Touch to register your avatar name and UUID", <1,1,1>, 1);
  8. }
  9. touch_start(integer howmany)
  10. {
  11. integer i;
  12. llSetText("Sending...", <1,0,0>, 1);
  13. for (i = 0; i < howmany; i++) {
  14. http_request_id = llHTTPRequest(touchURL + "?name=" + llEscapeURL(llDetectedName(i)) +
  15. "&amp;key=" + llEscapeURL(llDetectedKey(i)), [], "");
  16. llSetTimerEvent(360.0);
  17. }
  18. llSetText("Touch to register your avatar name and UUID", <1,1,1>, 1);
  19. }
  20. timer()
  21. {
  22. llWhisper(0, "No response from web services...");
  23. llResetScript();
  24. }
  25. http_response(key request_id, integer status, list metadata, string body)
  26. {
  27. if (request_id == http_request_id)
  28. {
  29. if (status == 200)
  30. llWhisper(0, body);
  31. else
  32. llWhisper(0, "Error " + (string)status + ": " + body);
  33. llSetTimerEvent(0.0);
  34. }
  35. }
  36. }