diff options
Diffstat (limited to 'onefang's_utilities_manual.txt')
| -rw-r--r-- | onefang's_utilities_manual.txt | 228 |
1 files changed, 228 insertions, 0 deletions
diff --git a/onefang's_utilities_manual.txt b/onefang's_utilities_manual.txt new file mode 100644 index 0000000..dcb4f9a --- /dev/null +++ b/onefang's_utilities_manual.txt | |||
| @@ -0,0 +1,228 @@ | |||
| 1 | A bunch of stuff copied from the script, since it's too close to the 64Kb limit. | ||
| 2 | Below the license is some rough instructions. | ||
| 3 | |||
| 4 | // onefang's utilites version 3.0 | ||
| 5 | // Read a complete settings notecard and send settings to other scripts. | ||
| 6 | // Also other useful functions. | ||
| 7 | |||
| 8 | // Copyright (C) 2007 David Seikel (onefang rejected). | ||
| 9 | // | ||
| 10 | // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 11 | // of this software and associated documentation files (the "Software"), to | ||
| 12 | // deal in the Software without restriction, including without limitation the | ||
| 13 | // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
| 14 | // sell copies of the Software, and to permit persons to whom the Software is | ||
| 15 | // furnished to do so, subject to the following conditions: | ||
| 16 | // | ||
| 17 | // The above copyright notice and this permission notice shall be included in | ||
| 18 | // all copies of the Software and its Copyright notices. In addition publicly | ||
| 19 | // documented acknowledgment must be given that this software has been used if no | ||
| 20 | // source code of this software is made available publicly. This includes | ||
| 21 | // acknowledgments in either Copyright notices, Manuals, Publicity and Marketing | ||
| 22 | // documents or any documentation provided with any product containing this | ||
| 23 | // software. This License does not apply to any software that links to the | ||
| 24 | // libraries provided by this software (statically or dynamically), but only to | ||
| 25 | // the software provided. | ||
| 26 | // | ||
| 27 | // Please see the COPYING-PLAIN for a plain-english explanation of this notice | ||
| 28 | // and it's intent. | ||
| 29 | // | ||
| 30 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 31 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 32 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
| 33 | // THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 34 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 35 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 36 | // | ||
| 37 | // As a special exception to the above conditions, the Second Life user known | ||
| 38 | // as Winter Ventura may ignore all permissions and conditions and provide her | ||
| 39 | // own. | ||
| 40 | |||
| 41 | // All scripts in this object will get link messages with - | ||
| 42 | // num = -1000 - line number in the notecard. | ||
| 43 | // message = a list, | ||
| 44 | // settings card name, | ||
| 45 | // name of this setting, | ||
| 46 | // data for this setting (may be ""). | ||
| 47 | // id = scriptKey as passed to us by the calling script. | ||
| 48 | // Settings are in the format "setting=data" with whitespace ignored. | ||
| 49 | // # as first non space character means ignore the line. | ||
| 50 | // For best efficiency, keep notecards short, 0.1 seconds per line read. | ||
| 51 | // You can seperate settings with a ";", and include a literal ";" with "\;". | ||
| 52 | // Objects using this must be tolerant of having their settings passed | ||
| 53 | // to them at any time, even multiple times. | ||
| 54 | // Other scripts should ignore settings that are meaningless to them, | ||
| 55 | // but can complain if settings they know about are broken. | ||
| 56 | // | ||
| 57 | // Other commands are passed in link messages in the form - | ||
| 58 | // llMessageLink(LINK_SET, UTILITIES_COMMAND, llDumpList2String(argumentList, LIST_SEP), scriptKey); | ||
| 59 | // UTILITIES_COMMAND is one of the commands listed below. | ||
| 60 | // argumentList is a list of the arguments for the command. | ||
| 61 | // For those commands with one or less arguments, a dumped list is not needed. | ||
| 62 | // scriptKEy is llGetInventoryKey(llGetScriptName()) from the caller script. | ||
| 63 | // It's used by the caller to make sure it gets it's returned message and not that of other scripts. | ||
| 64 | |||
| 65 | // llGetNotecardLine() delays for 0.1 seconds, truncates at 255 chars, no warning, 64KiB notecard limit. | ||
| 66 | // llResetOtherScript("SettingsReaderAndUtilities") to restart this from another script. | ||
| 67 | |||
| 68 | // TODO (LSL permitting) - | ||
| 69 | // Use numbers for the returned chat commands. | ||
| 70 | // These numbers are set by the caller. | ||
| 71 | // They only should set a base number, that gets incremented for the other commands. | ||
| 72 | // Performance monitor. | ||
| 73 | // onefangs special boolean parser, put it in there somewhere. | ||
| 74 | // More complex parsing - | ||
| 75 | // No = required, just parse first word as key, rest as data. | ||
| 76 | // Does not work so well for "Avatar Name=key". | ||
| 77 | // Other comment types, embedded comments. | ||
| 78 | |||
| 79 | // type channel owner prefix commands menu scripts users | ||
| 80 | // emoter 12+123 only none no 1 owner | ||
| 81 | // translator 1+2+3 only none no 1 owner | ||
| 82 | // online HUD 5 only fixed+ no 1 owner | ||
| 83 | // online IRC 0 +IRC fixed+ no 1 owner+IRC nick | ||
| 84 | // hug 1 only config later 1 owner+hugee | ||
| 85 | // TeddyPorter 2 owners TeddyPorter fixed+ yes 1+ owners+bookers+occupier+group+users | ||
| 86 | // collar 0+x owners *|an per script yes several owner+secowners+group+sub+everyone | ||
| 87 | |||
| 88 | // Online IRC is TODO'd to move away from the need to listen to local chat. | ||
| 89 | // Collars are icky, but mired in historical precedence. | ||
| 90 | // TeddyPorter is the only other one with an open listener, and it uses a prefix to filter because of that. | ||
| 91 | |||
| 92 | |||
| 93 | |||
| 94 | integer isKey(key thisKey) | ||
| 95 | {//by: Strife Onizuka | ||
| 96 | if (thisKey) return 2; // key is valid AND not equal NULL_KEY; the distinction is important in some cases (return value of 2 is still evaluated as unary boolean TRUE) | ||
| 97 | return (thisKey == NULL_KEY); // key is valid AND equal to NULL_KEY (return 1 or TRUE), or is not valid (return 0 or FALSE) | ||
| 98 | } | ||
| 99 | |||
| 100 | key forceKey(key thisKey) | ||
| 101 | {//force a string or key to be a valid key assuming you want invalids to become NULL_KEY | ||
| 102 | if (thisKey) return thisKey; | ||
| 103 | return NULL_KEY; | ||
| 104 | } | ||
| 105 | |||
| 106 | // If the above key checking turns out to be wrong, do it the hard way. | ||
| 107 | integer isKeyHard(key thisKey) | ||
| 108 | { | ||
| 109 | integer i; | ||
| 110 | |||
| 111 | if (llStringLength(thisKey) != 36) | ||
| 112 | return FALSE; | ||
| 113 | // Hyphenation tests: | ||
| 114 | if (llGetSubString(thisKey, 8, 8) != "-") | ||
| 115 | return FALSE; | ||
| 116 | if (llGetSubString(thisKey, 13, 13) != "-") | ||
| 117 | return FALSE; | ||
| 118 | if (llGetSubString(thisKey, 18, 18) != "-") | ||
| 119 | return FALSE; | ||
| 120 | if (llGetSubString(thisKey, 23, 23) != "-") | ||
| 121 | return FALSE; | ||
| 122 | // Hex test: | ||
| 123 | // Remove dashes (fixed, thanks Kek :-)) | ||
| 124 | thisKey = llDeleteSubString(llDeleteSubString(llDeleteSubString(llDeleteSubString((string) thisKey, 23, 23), 18, 18), 13, 13), 8, 8); | ||
| 125 | |||
| 126 | for (i = 0; i < 32; ++i) | ||
| 127 | { | ||
| 128 | string char = llGetSubString(thisKey, i, i); | ||
| 129 | |||
| 130 | if ((0 == ((integer) ("0x" + char))) && ("0" != char)) | ||
| 131 | return FALSE; | ||
| 132 | } | ||
| 133 | return TRUE; // Passed all tests: | ||
| 134 | } | ||
| 135 | |||
| 136 | // Send an avatar key request to the server. | ||
| 137 | addKeyRequest(key script, string type, string name, string extra) | ||
| 138 | { | ||
| 139 | keyRequests += [script, type, name, extra, llHTTPRequest("http://w-hat.com/name2key?terse=1&name=" + llEscapeURL(name), [], "")]; | ||
| 140 | } | ||
| 141 | |||
| 142 | |||
| 143 | |||
| 144 | |||
| 145 | // Check if anything changed. | ||
| 146 | // Including - adding inv, deleting inv, change name or desc of inv, saving notecard, recompiling script. | ||
| 147 | // Not including - script reset, no-copy inv is dragged out, inv drop by non owner. | ||
| 148 | //changed(integer change) | ||
| 149 | //{ | ||
| 150 | //if (CHANGED_INVENTORY & change) | ||
| 151 | //init(settingsName); | ||
| 152 | //} | ||
| 153 | |||
| 154 | // Deal with each notecard line. | ||
| 155 | dataserver(key query_id, string data) | ||
| 156 | { | ||
| 157 | if (query_id == settingsQueryID) | ||
| 158 | { | ||
| 159 | if (data != EOF) | ||
| 160 | { | ||
| 161 | readThisLine(data); | ||
| 162 | settingsQueryID = llGetNotecardLine(settingsName, settingsLine); | ||
| 163 | } | ||
| 164 | else | ||
| 165 | { | ||
| 166 | llMessageLinked(LINK_SET, UTILITIES_READ_DONE, settingsName, settingsKey); | ||
| 167 | startNextRead(); | ||
| 168 | } | ||
| 169 | } | ||
| 170 | } | ||
| 171 | |||
| 172 | http_response(key id, integer status, list meta, string body) | ||
| 173 | { | ||
| 174 | integer i; | ||
| 175 | integer length = llGetListLength(keyRequests) / KEYS_STRIDE; | ||
| 176 | |||
| 177 | for (i = 0; i <= length; ++i) | ||
| 178 | { | ||
| 179 | integer thisRequest = i * KEYS_STRIDE; | ||
| 180 | |||
| 181 | if ((NULL_KEY != id) && (llList2Key(keyRequests, thisRequest + KEYS_ID) == id)) | ||
| 182 | { | ||
| 183 | string script = llList2String(keyRequests, thisRequest + KEYS_SCRIPT); | ||
| 184 | string type = llList2String(keyRequests, thisRequest + KEYS_TYPE); | ||
| 185 | string name = llList2String(keyRequests, thisRequest + KEYS_NAME); | ||
| 186 | string extra = llList2String(keyRequests, thisRequest + KEYS_EXTRA); | ||
| 187 | key result = (key) body; | ||
| 188 | |||
| 189 | keyRequests = llDeleteSubList(keyRequests, thisRequest, thisRequest + KEYS_STRIDE - 1); | ||
| 190 | i -= KEYS_STRIDE; | ||
| 191 | length -= KEYS_STRIDE; | ||
| 192 | |||
| 193 | if (status == 499) | ||
| 194 | { | ||
| 195 | llOwnerSay("name2key request timed out for " + name + ". Trying again."); | ||
| 196 | addKeyRequest(script, type, name, extra); | ||
| 197 | } | ||
| 198 | else if (status != 200) | ||
| 199 | { | ||
| 200 | llOwnerSay("The internet exploded!! Trying again."); | ||
| 201 | addKeyRequest(script, type, name, extra); | ||
| 202 | } | ||
| 203 | else if ((!isKey(result)) || ("" == body)) | ||
| 204 | llOwnerSay("No key found for " + name); | ||
| 205 | else if (36 != llStringLength(body)) | ||
| 206 | llOwnerSay("Server broken for " + name); | ||
| 207 | else | ||
| 208 | llMessageLinked(LINK_SET, UTILITIES_AVATAR_KEY_DONE, llDumpList2String([type, name, result, extra], LIST_SEP), script); | ||
| 209 | } | ||
| 210 | } | ||
| 211 | } | ||
| 212 | |||
| 213 | |||
| 214 | else if (UTILITIES_AVATAR_KEY == num) | ||
| 215 | { | ||
| 216 | string type = llList2String(input, 0); | ||
| 217 | string name = llList2String(input, 1); | ||
| 218 | string extra = llList2String(input, 2); | ||
| 219 | key result = NULL_KEY; | ||
| 220 | |||
| 221 | // TODO add a check for the key already existing in name. Should be done by caller if caller worries about speed. | ||
| 222 | |||
| 223 | if (NULL_KEY == result) | ||
| 224 | addKeyRequest(id, type, name, extra); | ||
| 225 | else | ||
| 226 | llMessageLinked(LINK_SET, num - 1, llDumpList2String([type, name, result, extra], LIST_SEP), id); | ||
| 227 | } | ||
| 228 | |||
