2 // huffware script: html onna prim, by fred huffhines.
4 // sets the land's media to a web site.
6 // this script is licensed by the GPL v3 which is documented at: http://www.gnu.org/licenses/gpl.html
7 // do not use it in objects without fully realizing you are implicitly accepting that license.
10 integer initted = FALSE;
13 // huffware script: auto-retire, by fred huffhines, version 1.9.
14 // distributed under BSD-like license.
15 // partly based on the self-upgrading scripts from markov brodsky and jippen faddoul.
16 // the function auto_retire() should be added *inside* a version numbered script that
17 // you wish to give the capability of self-upgrading.
18 // this script supports a notation for versions embedded in script names where a 'v'
19 // is followed by a number in the form "major.minor", e.g. "grunkle script by ted v8.2".
20 // when the containing script is dropped into an object with a different version, the
21 // most recent version eats any existing ones.
22 // keep in mind that this code must be *copied* into your script you wish to add
23 // auto-retirement capability to.
25 // example usage of the auto-retirement script:
29 // auto_retire(); // make sure newest addition is only version of script.
33 string self = llGetScriptName(); // the name of this script.
34 list split = compute_basename_and_version(self);
35 if (llGetListLength(split) != 2) return; // nothing to do for this script.
36 string basename = llList2String(split, 0); // script name with no version attached.
37 string version_string = llList2String(split, 1); // the version found.
39 // find any scripts that match the basename. they are variants of this script.
40 for (posn = llGetInventoryNumber(INVENTORY_SCRIPT) - 1; posn >= 0; posn--) {
41 string curr_script = llGetInventoryName(INVENTORY_SCRIPT, posn);
42 if ( (curr_script != self) && (llSubStringIndex(curr_script, basename) == 0) ) {
43 // found a basic match at least.
44 list inv_split = compute_basename_and_version(curr_script);
45 if (llGetListLength(inv_split) == 2) {
46 // see if this script is more ancient.
47 string inv_version_string = llList2String(inv_split, 1); // the version found.
48 if ((float)inv_version_string < (float)version_string) {
49 // remove script with same name from inventory that has inferior version.
50 llRemoveInventory(curr_script);
57 // separates the base script name and version number. used by auto_retire.
58 list compute_basename_and_version(string to_chop_up)
60 if (llSubStringIndex(to_chop_up, " ") < 0) return []; // no space found, not a valid name to work on.
62 string basename = to_chop_up; // script name with no version attached.
65 // minimum script name is 2 characters plus version.
66 for (posn = llStringLength(to_chop_up) - 1;
67 (posn >= 2) && (llGetSubString(to_chop_up, posn, posn) != " ");
69 // find the space. do nothing else.
71 if (posn < 2) return []; // no space found.
72 string full_suffix = llGetSubString(to_chop_up, posn, -1);
73 // ditch the space character for our numerical check.
74 string chop_suffix = llGetSubString(full_suffix, 1, llStringLength(full_suffix) - 1);
75 // strip out a 'v' if there is one.
76 if (llGetSubString(chop_suffix, 0, 0) == "v")
77 chop_suffix = llGetSubString(chop_suffix, 1, llStringLength(chop_suffix) - 1);
78 // if valid floating point number and greater than zero, that works for our version.
79 if ((float)chop_suffix > 0.0) {
80 // this is a big success right here.
81 basename = llGetSubString(to_chop_up, 0, -llStringLength(full_suffix) - 1);
82 return [ basename, chop_suffix ];
84 // seems like we found nothing useful.
92 state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; }
93 on_rez(integer parm) { state rerun; }
95 state rerun { state_entry() { state default; } }
105 on_rez(integer parm) {
109 touch_start(integer count) {
110 if ( llParcelMediaQuery([PARCEL_MEDIA_COMMAND_TEXTURE]) == [] ) {
111 llSay(0, "Lacking permission to set/query parcel media. This object has to be owned by/deeded to the land owner.");
115 string texture_name = llGetInventoryName(INVENTORY_TEXTURE, 0);
116 // sets the media texture to the first texture found in our inventory.
117 llParcelMediaCommandList( [
118 PARCEL_MEDIA_COMMAND_URL, "http://gruntose.com",
119 PARCEL_MEDIA_COMMAND_TYPE, "text/html",
120 PARCEL_MEDIA_COMMAND_TEXTURE, llGetInventoryKey(texture_name),
121 PARCEL_MEDIA_COMMAND_PLAY ] );
122 llSetTexture(texture_name, ALL_SIDES);
127 llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_STOP]);
128 llParcelMediaCommandList([PARCEL_MEDIA_COMMAND_PLAY]);