sloodle_rezzer_object.lslp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. /*********************************************
  4. * Copyright (c) 2009 - 2011 various contributors (see below)
  5. * Released under the GNU GPL 3.0
  6. * This script can be used in your scripts, but you must include this copyright header as per the GPL Licence
  7. * For more information about GPL 3.0 - see: http://www.gnu.org/copyleft/gpl.html
  8. * This script is part of the SLOODLE Project see http://sloodle.org
  9. *
  10. * sloodle_rezzer_object
  11. * Copyright:
  12. * Paul G. Preibisch (Fire Centaur in SL) fire@avatarclassroom.com
  13. * Edmund Edgar (Edmund Earp in SL) ed@avatarclassroom.com
  14. *
  15. * This script will get an httpin url, and shout it out to the rezzer. It will then wait to receive its config via httpin, and send it as a linked message to all other scripts
  16. */
  17. integer SLOODLE_CHANNEL_HTTP_RESPONSE = -1639260101; // Tells the sloodle_rezzer_object script to send the contents as an http-in response, to the key specified as key, which should be waiting for a response.
  18. integer SLOODLE_CHANNEL_OBJECT_DIALOG = -3857343;//configuration channel
  19. integer SLOODLE_CHANNEL_OBJECT_CREATOR_REQUEST_CONFIGURATION_VIA_HTTP_IN_URL = -1639270089; //Object creator telling itself it wants to rez an object at a position (specified as key)
  20. string SLOODLE_HTTP_IN_REQUEST_LINKER = "/mod/sloodle/classroom/httpin_config_linker.php";
  21. string SLOODLE_HTTP_IN_UPDATE_LINKER = "/mod/sloodle/classroom/httpin_url_update_linker.php";
  22. string SLOODLE_PING_LINKER = "/mod/sloodle/classroom/active_object_ping_linker.php";
  23. integer SLOODLE_CHANNEL_SET_CLEANUP_AND_DEREZ = -1639270131; // linked message to tell the object to derez if it has some object-specific cleanup tasks.
  24. float refreshseconds = 3600.0; // Number of seconds between pings. Some jitter will sometimes be added to prevent killing the server this number of seconds after a sim full of objects starts up. We start with a fairly slow default, but this can be altered by the server when we ping or send out config.
  25. string SLOODLE_EOF = "sloodleeof";
  26. vector rezzer_position_offset;
  27. rotation rezzer_rotation_offset;
  28. key rezzer_uuid;
  29. integer isconfigured = 0;
  30. integer has_position = 0;
  31. integer http_in_password = 0;
  32. string sloodlepwd = "";
  33. string sloodleserverroot = "";
  34. string sloodlecontrollerid = "";
  35. string myUrl;
  36. string persistent_config;
  37. integer is_pinging = 0;
  38. integer is_ping_retry = 0;
  39. key current_ping_http = NULL_KEY;
  40. move_to_layout_position() {
  41. // llOwnerSay("todo: move to position "+(string)rezzer_position_offset+", rot "+(string)rezzer_rotation_offset+ " in relation to rezzer "+(string)rezzer_uuid);
  42. list rezzerdetails = llGetObjectDetails( rezzer_uuid, [ OBJECT_POS, OBJECT_ROT ] );
  43. vector rezzerpos = llList2Vector( rezzerdetails, 0 );
  44. rotation rezzerrot = llList2Rot( rezzerdetails, 1 );
  45. sloodle_set_pos( rezzerpos + ( rezzer_position_offset * rezzerrot ) );
  46. llSetRot( rezzerrot * rezzer_rotation_offset );
  47. }
  48. // Configure by receiving a linked message from another script in the object
  49. // Returns TRUE if the object has all the data it needs
  50. integer sloodle_handle_command(string str, integer do_persist)
  51. {
  52. // llOwnerSay("handling command "+str);
  53. list bits = llParseString2List(str,["|"],[]);
  54. integer numbits = llGetListLength(bits);
  55. if (numbits >= 1 ) {
  56. string name = llList2String(bits,0);
  57. string value1 = "";
  58. string value2 = "";
  59. if (numbits > 1) value1 = llList2String(bits,1);
  60. if (numbits > 2) value2 = llList2String(bits,2);
  61. if (name == "set:sloodleserverroot") { sloodleserverroot = value1;
  62. } else if (name == "set:sloodlepwd") { sloodlepwd = value1 + "|" + value2;
  63. } else if (name == "set:sloodlecontrollerid") { sloodlecontrollerid = value1;
  64. } else if (name == "set:position") {
  65. rezzer_position_offset = (vector)llList2String(bits,1);
  66. rezzer_rotation_offset = (rotation)llList2String(bits,2);
  67. rezzer_uuid = llList2Key(bits,3);
  68. has_position = 1;
  69. } else if (name == "do:derez") {
  70. // If there is a script designed to handle derezzing, send it a message.
  71. // It should do anything it needs to do, like saving inventory or derezzing child objects...
  72. // ...then derez itself when it's done.
  73. if (llGetInventoryType( "sloodle_rezzer_derez_handler" ) == INVENTORY_SCRIPT) {
  74. llMessageLinked(LINK_SET, SLOODLE_CHANNEL_SET_CLEANUP_AND_DEREZ, "", NULL_KEY);
  75. } else {
  76. llSleep(2); // This is needed to give the script a chance to finish making the http response.
  77. llDie();
  78. }
  79. } else if ( (name=="do:requestconfig") || (name=="do:reset") ) {
  80. string this_script = llGetScriptName();
  81. integer n = llGetInventoryNumber(INVENTORY_SCRIPT);
  82. while(n) {
  83. string script_name = llGetInventoryName(INVENTORY_SCRIPT, --n);
  84. // Reset all sloodle scripts. If for some reason we make a sloodle script that we don't want reset, call it "sloodle_reset".
  85. if ( (script_name != this_script) && (llGetSubString( script_name, 0, 7) == "sloodle_" ) && (llGetSubString( script_name, 0, 15) != "sloodle_noreset_" ) ) {
  86. llResetOtherScript( script_name );
  87. // llOwnerSay("resetting script "+script_name);
  88. }
  89. }
  90. // Give them a second to get started to avoid trying to configure them before they're ready.
  91. llSleep(1);
  92. state reinitialize;
  93. } else {
  94. if (do_persist == 1) {
  95. // llOwnerSay("adding to persist");
  96. persistent_config = persistent_config + "&" + name + "=" + value1;
  97. }
  98. }
  99. }
  100. if ( (sloodleserverroot != "") && (sloodlecontrollerid != "") && (sloodlepwd != "") ) {
  101. isconfigured = 1;
  102. }
  103. return isconfigured;
  104. }
  105. sloodle_tell_other_scripts(string msg, integer channel, key respond_key)
  106. {
  107. integer status_code;
  108. if (channel == 0) {
  109. // Don't know the channel yet - get it from the message.
  110. list lines;
  111. lines = llParseStringKeepNulls( msg, ["\n"], [] );
  112. string status_line = llList2String(lines, 0);
  113. list status_bits;
  114. status_bits = llParseStringKeepNulls( status_line, ["|"], [] );
  115. status_code = (integer)llList2String(status_bits, 0);
  116. if (status_code == 1) {
  117. status_code = SLOODLE_CHANNEL_OBJECT_DIALOG;
  118. }
  119. } else {
  120. status_code = channel;
  121. }
  122. // config requests need a SLOODLE_EOF on the end.
  123. // this is a legacy from sending notecards line-by-line.
  124. if (status_code == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  125. msg = msg + "\n"+SLOODLE_EOF;
  126. }
  127. // llOwnerSay("sending msg with status code "+(string)status_code+": "+msg);
  128. llMessageLinked(LINK_SET, status_code, msg, respond_key);
  129. }
  130. initialize()
  131. {
  132. //set timer to ask for config if config not received
  133. llSetTimerEvent(30);
  134. llSetText("", <1.0, 1.0, 1.0>, 1.0);
  135. rezzer_position_offset = <0,0,0>;
  136. rezzer_rotation_offset = <0,0,0,0>;
  137. rezzer_uuid = NULL_KEY;
  138. isconfigured = 0;
  139. has_position = 0;
  140. // http_in_password = 0;
  141. //get an httpin url
  142. if (myUrl != "") {
  143. llReleaseURL(myUrl);
  144. }
  145. llRequestURL();
  146. //llOwnerSay("initialize requesting url");
  147. }
  148. //sends our configuration to the server
  149. configure_from_persistent_config()
  150. {
  151. //llOwnerSay("got a persistent config, trying to use that");
  152. //send to httpin_config_linker
  153. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  154. body += "&sloodlepwd=" + sloodlepwd;
  155. body += "&sloodleobjuuid=" + (string)llGetKey();
  156. body += "&childobjectuuid=" + (string)llGetKey();
  157. body += "&httpinurl=" + myUrl;
  158. body += "&sloodleobjname=" + llGetObjectName();
  159. body += persistent_config;
  160. //llOwnerSay("requested config with body "+body);
  161. //tell the server to initialize via httpin using the specified parameters. Server will respond by sending an http response, AND the config via httpin, however
  162. //we will ingnore the http response, and instead, just use the httpin
  163. llHTTPRequest(sloodleserverroot + SLOODLE_HTTP_IN_REQUEST_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body+persistent_config);
  164. }
  165. update_http_in_url()
  166. {
  167. //llOwnerSay("got a persistent config, trying to use that");
  168. //send to httpin_config_linker
  169. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  170. body += "&sloodlepwd=" + sloodlepwd;
  171. body += "&sloodleobjuuid=" + (string)llGetKey();
  172. body += "&httpinurl=" + myUrl;
  173. //llOwnerSay("requested config with body "+body);
  174. llHTTPRequest(sloodleserverroot + SLOODLE_HTTP_IN_UPDATE_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body);
  175. }
  176. sloodle_set_pos(vector targetposition){
  177. integer counter=0;
  178. while ((llVecDist(llGetPos(), targetposition) > 0.001)&&(counter<50)) {
  179. counter+=1;
  180. llSetPos(targetposition);
  181. }
  182. }
  183. default{
  184. state_entry() {
  185. llSleep(1.0);
  186. initialize();
  187. }
  188. on_rez(integer start_param) {
  189. //llOwnerSay("default got start_param"+(string)start_param);
  190. //http_in_password is sent from the server - it is a random password per object so that malicious users can't send
  191. //commands to this object.
  192. http_in_password = start_param;
  193. //if no start_param, that means we were not rezzed by the rezzer (could have been by a user pulling fom inventory)
  194. if (start_param > 0) {
  195. //makesure config is clean
  196. sloodleserverroot = "";
  197. sloodlecontrollerid = "";
  198. sloodlepwd = "";
  199. persistent_config = "";
  200. }
  201. initialize();
  202. }
  203. http_request(key id, string method, string body){
  204. if ((method == URL_REQUEST_GRANTED)){
  205. //llOwnerSay("got url");
  206. myUrl=body;
  207. //shout it out to the rezzer our httpinUrl
  208. //persistant config is the data in memory from previous initialization
  209. // If we have a persistent config,
  210. if (persistent_config != "") {
  211. // llOwnerSay("config from persistent");
  212. //tell the server to configure us based on a configuration we had before which will will send via http request
  213. //we will then receive the returned config from the server via http-in
  214. configure_from_persistent_config();
  215. } else {
  216. // llOwnerSay("no persistent, contacting rezzer");
  217. //tell the rezzer to send us a configuration. Rezzer will tell the server to send us a configuration using our http-in
  218. llRegionSay(SLOODLE_CHANNEL_OBJECT_CREATOR_REQUEST_CONFIGURATION_VIA_HTTP_IN_URL,myUrl);
  219. //tell any other scripts our http-in
  220. llMessageLinked(LINK_THIS, SLOODLE_CHANNEL_OBJECT_CREATOR_REQUEST_CONFIGURATION_VIA_HTTP_IN_URL, myUrl, NULL_KEY);
  221. }
  222. } else if (method == "POST"){
  223. //this is where our object receives data from from our server via http-in
  224. list lines;
  225. lines = llParseStringKeepNulls( body, ["\n"], [] );
  226. list header_line;
  227. header_line = llParseStringKeepNulls( llList2String(lines,0), ["|"], [] );
  228. // Position 10 should be the http_in_password
  229. // This is set once on initial config.
  230. // Once we've implemented object persistance, it should always be set.
  231. if (http_in_password == 0) {
  232. // llOwnerSay("First time, setting http in password");
  233. http_in_password = (integer)llList2String(header_line, 10);
  234. }
  235. if (http_in_password != (integer)llList2String(header_line, 10)) {
  236. // llOwnerSay("Ignoring message - password mismatch");
  237. llHTTPResponse(id, 401, "Unauthorized - HTTP-in password mismatch");
  238. return;
  239. }
  240. // If we don't expect a response from the script that handles this, respond now to say we got the message.
  241. integer expect_response = 0;
  242. if (llGetListLength(header_line) >= 12) {
  243. if (llList2Integer(header_line, 11) == 1) {
  244. expect_response = 1;
  245. }
  246. }
  247. if (expect_response != 1) {
  248. llHTTPResponse(id, 200, "OK");
  249. }
  250. if (llGetListLength(header_line) >= 13) {
  251. if (llList2Float(header_line,12) > 0) {
  252. refreshseconds = llList2Float(header_line,12);
  253. }
  254. }
  255. string descriptor = "";
  256. if (llGetListLength(header_line) > 1) descriptor = llList2String(header_line, 3);
  257. integer do_persist = 0;
  258. if ( (descriptor == "CONFIG_PERSISTENT") || (descriptor == "CONFIG") ) {
  259. // blow the existing config away and start again
  260. sloodleserverroot = "";
  261. sloodlecontrollerid = "";
  262. sloodlepwd = "";
  263. persistent_config = "";
  264. //This CONFIG_PERSISTENT setting is primarily for development purposes. We turn this setting off via serverside
  265. //when shipping, so our old settings are not saved in shipped versions. However, users server always defaults to
  266. //CONFIG_PERSISTENT so their settings are saved, not developmental ones
  267. //when the server sends a configuration via http-in, it tells the object to keep it in its resident memory
  268. if (descriptor == "CONFIG_PERSISTENT") {
  269. //this means that the script should store the config in its memory so that when it is taken into inventory, and re-rezzed, it will
  270. //still have a configuration
  271. do_persist = 1;
  272. }
  273. }
  274. integer numlines = llGetListLength(lines);
  275. integer i = 1;
  276. for (i=1; i < numlines; i++) {
  277. isconfigured = sloodle_handle_command(llList2String(lines, i), do_persist);
  278. }
  279. sloodle_tell_other_scripts(body,0, id);
  280. // This is the end of the configuration data
  281. llSleep(0.2);
  282. sloodle_tell_other_scripts(SLOODLE_EOF, 0, id);
  283. if (isconfigured == 1) {
  284. if (has_position == 1) {
  285. move_to_layout_position();
  286. }
  287. llSetTimerEvent(0);
  288. state ready;
  289. }
  290. }//endif
  291. }//http
  292. changed(integer change) {
  293. if ( (change & CHANGED_REGION_START) || (change & CHANGED_REGION ) ) {
  294. //Request new URL
  295. if (myUrl != "") {
  296. llReleaseURL(myUrl);
  297. }
  298. llRequestURL();
  299. }
  300. }
  301. timer() {
  302. initialize();
  303. }
  304. }
  305. state ready {
  306. on_rez(integer start_param)
  307. {
  308. // llOwnerSay("ready got start_param"+(string)start_param);
  309. http_in_password = start_param;
  310. if (start_param > 0) {
  311. sloodleserverroot = "";
  312. sloodlecontrollerid = "";
  313. sloodlepwd = "";
  314. persistent_config = "";
  315. // llSleep(2.0); // Give the rezzer time to register us. Seems to be an issue on OpenSim, where everything is faster than SL.
  316. }
  317. state default;
  318. }
  319. state_entry()
  320. {
  321. // llOwnerSay("ready state");
  322. // llOwnerSay(persistent_config);
  323. if (rezzer_uuid != NULL_KEY) {
  324. llListen(232323, "", rezzer_uuid, "");
  325. }
  326. }
  327. listen(integer channel, string name, key id, string message) {
  328. // Listen to the rezzer telling us it's moved, and move accordingly.
  329. // llOwnerSay(message);
  330. list bits = llParseString2List( message, ["|"], [] );
  331. vector change_pos = (vector)llList2String( bits, 0 );
  332. rotation change_rot = (rotation)llList2String( bits, 1 );
  333. vector parent_pos = (vector)llList2String( bits, 2);
  334. // llOwnerSay("got message" + message);
  335. // Apply the position changes first, then the rotation
  336. vector before_pos = llGetPos();
  337. if (before_pos.z > 0) { // sometimes this comes out at 0, but we don't want to go to the corner of the sim
  338. sloodle_set_pos( before_pos - change_pos );
  339. }
  340. before_pos = llGetPos();
  341. rotation before_rot = llGetRot();
  342. //llOwnerSay("Rot: "+(string)llRot2Euler(change_rot));
  343. // llOwnerSay((string)(before_rot - change_rot));
  344. // llOwnerSay("new pos: "+(string)(llGetPos() + ( before_pos - parent_pos) * change_rot));
  345. //change_rot = llEuler2Rot( < 0, 0, 15 * DEG_TO_RAD > ); // pretend we rotated 15 degrees
  346. vector currentPosition = llGetPos();
  347. vector currentOffset = currentPosition - parent_pos;
  348. //llOwnerSay("I plan to be "+(string)llVecDist(currentOffset, <0,0,0>)+" from parent");
  349. vector rotatedOffset = currentOffset * change_rot;
  350. vector newPosition = parent_pos + rotatedOffset;
  351. sloodle_set_pos(newPosition);
  352. //llOwnerSay("new pos: "+(string)(llGetPos() + ( ( before_pos - parent_pos) * change_rot ) ) );
  353. // llSetPos( before_pos + ( ( parent_pos - before_pos ) * change_rot ) );
  354. llSetRot( llGetRot() * change_rot );
  355. // llGetPos() + vPosOffset * llGetRot(), ZERO_VECTOR, llGetRot()
  356. }
  357. timer()
  358. {
  359. // Send our ping request
  360. string body = "sloodlecontrollerid=" + (string)sloodlecontrollerid;
  361. body += "&sloodlepwd=" + sloodlepwd;
  362. body += "&sloodleobjuuid=" + (string)llGetKey();
  363. is_pinging = 1;
  364. current_ping_http = llHTTPRequest(sloodleserverroot + SLOODLE_PING_LINKER, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "application/x-www-form-urlencoded"], body);
  365. }
  366. http_response( key request_id, integer status, list metadata, string body ){
  367. if (request_id != current_ping_http) {
  368. return;
  369. }
  370. list lines = llParseStringKeepNulls(body, ["\n"], []);
  371. list statusfields = llParseStringKeepNulls( llList2String(lines,0), ["|"], [] );
  372. if (llGetListLength(statusfields) >= 12) {
  373. if (llList2Float(statusfields,12) > 0) {
  374. refreshseconds = llList2Float(statusfields,12);
  375. }
  376. }
  377. is_pinging = 0;
  378. if (status == 200) {
  379. if (is_ping_retry == 1) {
  380. // Reintroduce the randomness we may have lost if the server went down.
  381. llSetTimerEvent(llFrand(refreshseconds));
  382. } else {
  383. llSetTimerEvent(refreshseconds);
  384. }
  385. is_ping_retry = 0;
  386. } else {
  387. is_ping_retry = 1;
  388. llSetTimerEvent(llFrand(refreshseconds));
  389. }
  390. }
  391. http_request(key id, string method, string body){
  392. if (method == URL_REQUEST_GRANTED){
  393. myUrl=body;
  394. update_http_in_url();
  395. } else if (method == "POST"){
  396. //this is where we receive data from from our server
  397. list lines;
  398. lines = llParseStringKeepNulls( body, ["\n"], [] );
  399. list header_line;
  400. header_line = llParseStringKeepNulls( llList2String(lines,0), ["|"], [] );
  401. // Position 10 should be the http_in_password
  402. // This is set once on initial config.
  403. // Once we've implemented object persistance, it should always be set.
  404. if (http_in_password == 0) {
  405. // llOwnerSay("First time, setting http in password");
  406. http_in_password = (integer)llList2String(header_line, 10);
  407. }
  408. if (http_in_password != (integer)llList2String(header_line, 10)) {
  409. // llOwnerSay("Ignoring message - password mismatch");
  410. llHTTPResponse(id, 401, "Unauthorized - HTTP-in password mismatch");
  411. return;
  412. }
  413. integer numlines = llGetListLength(lines);
  414. integer i = 0;
  415. // llOwnerSay(body);
  416. if (llList2String(header_line,3) == "REPORT_POSITION") {
  417. list rezzerdetails = llGetObjectDetails( rezzer_uuid, [ OBJECT_POS, OBJECT_ROT ] );
  418. vector rezzerpos = llList2Vector( rezzerdetails, 0 );
  419. rotation rezzerrot = llList2Rot( rezzerdetails, 1 );
  420. string reply = (string)( ( llGetPos() - rezzerpos ) / rezzerrot ) + "|" + (string)(llGetRot() / rezzerrot) + "|" + (string)rezzer_uuid;
  421. llHTTPResponse(id, 200, reply);
  422. return;
  423. }
  424. // If we don't expect a response from the script that handles this, respond now to say we got the message.
  425. integer expect_response = 0;
  426. if (llGetListLength(header_line) >= 12) {
  427. if (llList2Integer(header_line, 11) == 1) {
  428. expect_response = 1;
  429. }
  430. };
  431. if (expect_response != 1) {
  432. llHTTPResponse(id, 200, "OK");
  433. }
  434. string status_descriptor = "";
  435. string request_descriptor = "";
  436. integer do_persist = 0;
  437. if (llGetListLength(header_line) > 1) status_descriptor = llList2String(header_line, 1);
  438. if (llGetListLength(header_line) > 2) request_descriptor = llList2String(header_line, 3);
  439. if ( (request_descriptor == "CONFIG_PERSISTENT") || (request_descriptor == "CONFIG") ) {
  440. // blow the existing config away and start again
  441. sloodleserverroot = "";
  442. sloodlecontrollerid = "";
  443. sloodlepwd = "";
  444. persistent_config = "";
  445. if (request_descriptor == "CONFIG_PERSISTENT") {
  446. do_persist = 1;
  447. }
  448. }
  449. if ( (status_descriptor == "CONFIG") || (status_descriptor=="SYSTEM") ){
  450. for (i=1; i < numlines; i++) {
  451. isconfigured = sloodle_handle_command(llList2String(lines, i), do_persist);
  452. }
  453. }
  454. sloodle_tell_other_scripts(body, 0, id);
  455. // This is the end of the configuration data
  456. llSleep(0.2);
  457. sloodle_tell_other_scripts(SLOODLE_EOF, 0, id);
  458. // Start pinging, with jitter
  459. llSetTimerEvent(llFrand(refreshseconds));
  460. }//endif
  461. }//http
  462. changed(integer change) {
  463. if ( (change & CHANGED_REGION_START) || (change & CHANGED_REGION ) ) {
  464. //Request new URL
  465. if (myUrl != "") {
  466. llReleaseURL(myUrl);
  467. }
  468. llRequestURL();
  469. }
  470. }
  471. link_message(integer sender_num, integer num, string str, key id)
  472. {
  473. // Check the channel
  474. if (num == SLOODLE_CHANNEL_OBJECT_DIALOG) {
  475. sloodle_handle_command(str, 0);
  476. } else if (num == SLOODLE_CHANNEL_HTTP_RESPONSE) {
  477. llHTTPResponse(id, 200, str);
  478. }
  479. }
  480. }
  481. state reinitialize {
  482. // force us to go into state default and run state_entry, which calls initialize
  483. // this allows us to get to that state from a function that doesn't know whether it's already in state default or not.
  484. state_entry() {
  485. state default;
  486. }
  487. }
  488. // Please leave the following line intact to show where the script lives in Git:
  489. // SLOODLE LSL Script Git Location: mod/set-1.0/objects/default/assets/sloodle_rezzer_object.lslp