2 // huffware script: begging bowl, by fred huffhines.
4 // handles gifts from visitors at our shop.
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.
12 integer BEGGING_INTERVAL = 8;
13 // the period (in seconds) of our asking the avatar for money.
14 // keeping this reasonably high ensures that the begging jar isn't
15 // too noisy if someone is whanging away at it to play the sound or
18 // variables, some with initializers.
20 integer last_begging_time; // when we last pleaded for additional funding.
22 integer tip_amount; // the amount given to us just recently.
23 integer total_tips = 638;
24 // 108 -- aug 30 2008 or so. 214 -- nov 28 2008. 342 -- dec 28 2008.
25 // 486 -- mar 21 2009. 589 -- may 12 2009. 632 -- aug 02 2009.
26 // 638 -- aug 31 2009.
27 key tippers_key = NULL_KEY; // the key for the avatar that has tipped us.
28 string last_tipper; // the name of the last tipper.
32 string msg = "{ eepaw tipster }\ntouch for more info...\n.\nL$"
33 + (string)total_tips + " donated so far--thanks!";
34 if (last_tipper != "")
35 msg += "\nLast recvd L$" + (string)tip_amount + " from " + last_tipper + ", yay!";
36 llSetText(msg, <0.8, 0.6, 0.9>, 1);
39 initialize_begging_bowl()
42 llOwnerSay("ready to receive tips from customers...");
44 last_begging_time = llGetUnixTime(); // reset just to have some kindo value.
48 thank_tipper_and_give_gifts(string name)
50 llSay(0, "eepaw shop and its workers thank you for the tip, " + name + "!");
51 last_tipper = name; // store this for our text.
52 string first_name = llDeleteSubString(name, llSubStringIndex(name, " "), -1);
53 llInstantMessage(tippers_key, first_name + ", thank you very much for your tip of L$"
54 + (string)tip_amount + ", from all of us at eepaw shop.");
55 llOwnerSay("received tip from " + name + " of L$" + (string)tip_amount + ".");
56 if (llGetInventoryNumber(INVENTORY_SOUND)) {
57 // we will only play one sound currently.
58 llPlaySound(llGetInventoryName(INVENTORY_SOUND, 0 ), 1.0);
61 // give out pictures, notecards and objects that are hiding in the object.
63 list all_to_give; // the full set of gifts.
64 for (indy = 0; indy < llGetInventoryNumber(INVENTORY_TEXTURE); indy++)
65 all_to_give += llGetInventoryName(INVENTORY_TEXTURE, indy);
66 for (indy = 0; indy < llGetInventoryNumber(INVENTORY_NOTECARD); indy++)
67 all_to_give += llGetInventoryName(INVENTORY_NOTECARD, indy);
68 for (indy = 0; indy < llGetInventoryNumber(INVENTORY_OBJECT); indy++)
69 all_to_give += llGetInventoryName(INVENTORY_OBJECT, indy);
70 for (indy = 0; indy < llGetInventoryNumber(INVENTORY_OBJECT); indy++)
71 all_to_give += llGetInventoryName(INVENTORY_SOUND, indy);
72 // pick a semi-meaningful folder name.
73 string gift_folder_name = "eepaw thanky! (you gave us L$"
74 + (string)tip_amount + " on " + llGetDate() + ")";
76 llGiveInventoryList(tippers_key, gift_folder_name, all_to_give);
78 total_tips += tip_amount;
79 llOwnerSay("tips so far: L$" + (string)total_tips + ".");
80 show_label(); // refresh our text label.
83 handle_being_touched(integer num) {
84 // make sure we've waited enough time before begging again.
85 if (llAbs(llGetUnixTime() - last_begging_time) > BEGGING_INTERVAL) {
87 "\nIt would be awesome if you could tip our hardworking widget gnomes.\n"
88 + "If you right-click this object, you can 'Pay' it a tip, which will\n"
89 + "go directly to the eepaw shop personnel. Thanks much!");
90 // update our last begging time so we don't beg too often.
91 last_begging_time = llGetUnixTime();
93 // explode the textures just a little bit, if we have any on hand.
95 for (indy = 0; indy < llGetInventoryNumber(INVENTORY_TEXTURE); indy++) {
96 llMakeExplosion(14, .4, 0.5, 4, 0.8,
97 llGetInventoryName(INVENTORY_TEXTURE, indy), <0.0, 0.0, 0.0>);
99 // play the last sound that we happen to have, if any at all.
100 llPlaySound(llGetInventoryName(INVENTORY_SOUND, llGetInventoryNumber(INVENTORY_SOUND) - 1), 1.0);
104 // huffware script: auto-retire, by fred huffhines, version 2.5.
105 // distributed under BSD-like license.
106 // !! keep in mind that this code must be *copied* into another
107 // !! script that you wish to add auto-retirement capability to.
108 // when a script has auto_retire in it, it can be dropped into an
109 // object and the most recent version of the script will destroy
110 // all older versions.
112 // the version numbers are embedded into the script names themselves.
113 // the notation for versions uses a letter 'v', followed by two numbers
114 // in the form "major.minor".
115 // major and minor versions are implicitly considered as a floating point
116 // number that increases with each newer version of the script. thus,
117 // "hazmap v0.1" might be the first script in the "hazmap" script continuum,
118 // and "hazmap v3.2" is a more recent version.
120 // example usage of the auto-retirement script:
123 // auto_retire(); // make sure newest addition is only version of script.
126 // this script is partly based on the self-upgrading scripts from markov brodsky
127 // and jippen faddoul.
130 string self = llGetScriptName(); // the name of this script.
131 list split = compute_basename_and_version(self);
132 if (llGetListLength(split) != 2) return; // nothing to do for this script.
133 string basename = llList2String(split, 0); // script name with no version attached.
134 string version_string = llList2String(split, 1); // the version found.
136 // find any scripts that match the basename. they are variants of this script.
137 for (posn = llGetInventoryNumber(INVENTORY_SCRIPT) - 1; posn >= 0; posn--) {
138 //log_it("invpo=" + (string)posn);
139 string curr_script = llGetInventoryName(INVENTORY_SCRIPT, posn);
140 if ( (curr_script != self) && (llSubStringIndex(curr_script, basename) == 0) ) {
141 // found a basic match at least.
142 list inv_split = compute_basename_and_version(curr_script);
143 if (llGetListLength(inv_split) == 2) {
144 // see if this script is more ancient.
145 string inv_version_string = llList2String(inv_split, 1); // the version found.
146 // must make sure that the retiring script is completely the identical basename;
147 // just matching in the front doesn't make it a relative.
148 if ( (llList2String(inv_split, 0) == basename)
149 && ((float)inv_version_string < (float)version_string) ) {
150 // remove script with same name from inventory that has inferior version.
151 llRemoveInventory(curr_script);
158 // separates the base script name and version number. used by auto_retire.
159 list compute_basename_and_version(string to_chop_up)
161 // minimum script name is 2 characters plus a version.
162 integer space_v_posn;
163 // find the last useful space and 'v' combo.
164 for (space_v_posn = llStringLength(to_chop_up) - 3;
165 (space_v_posn >= 2) && (llGetSubString(to_chop_up, space_v_posn, space_v_posn + 1) != " v");
167 // look for space and v but do nothing else.
168 //log_it("pos=" + (string)space_v_posn);
170 if (space_v_posn < 2) return []; // no space found.
171 //log_it("space v@" + (string)space_v_posn);
172 // now we zoom through the stuff after our beloved v character and find any evil
173 // space characters, which are most likely from SL having found a duplicate item
174 // name and not so helpfully renamed it for us.
176 for (indy = llStringLength(to_chop_up) - 1; indy > space_v_posn; indy--) {
177 //log_it("indy=" + (string)space_v_posn);
178 if (llGetSubString(to_chop_up, indy, indy) == " ") {
179 // found one; zap it. since we're going backwards we don't need to
180 // adjust the loop at all.
181 to_chop_up = llDeleteSubString(to_chop_up, indy, indy);
182 //log_it("saw case of previously redundant item, aieee. flattened: " + to_chop_up);
185 string full_suffix = llGetSubString(to_chop_up, space_v_posn, -1);
186 // ditch the space character for our numerical check.
187 string chop_suffix = llGetSubString(full_suffix, 1, llStringLength(full_suffix) - 1);
188 // strip out a 'v' if there is one.
189 if (llGetSubString(chop_suffix, 0, 0) == "v")
190 chop_suffix = llGetSubString(chop_suffix, 1, llStringLength(chop_suffix) - 1);
191 // if valid floating point number and greater than zero, that works for our version.
192 string basename = to_chop_up; // script name with no version attached.
193 if ((float)chop_suffix > 0.0) {
194 // this is a big success right here.
195 basename = llGetSubString(to_chop_up, 0, -llStringLength(full_suffix) - 1);
196 return [ basename, chop_suffix ];
198 // seems like we found nothing useful.
206 state_entry() { if (llSubStringIndex(llGetObjectName(), "huffotronic") < 0) state real_default; }
207 on_rez(integer parm) { state rerun; }
209 state rerun { state_entry() { state default; } }
215 initialize_begging_bowl();
218 touch_start(integer num) {
219 handle_being_touched(num);
222 money(key id, integer payment) {
223 tip_amount = payment;
225 llRequestAgentData(id, DATA_NAME);
228 dataserver(key query, string name) { thank_tipper_and_give_gifts(name); }