lslsnips
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| lslsnips [2025/09/24 21:51] – created miko | lslsnips [2025/12/11 12:05] (current) – Discussion status changed miko | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ===== Create | + | ===== Create |
| + | 🛠️ How It Works | ||
| + | Listens on public chat (channel 0). | ||
| + | |||
| + | * Converts each character to Morse using a lookup list. | ||
| + | * Outputs Morse code with spaces between letters and slashes between words. | ||
| <code lsl> | <code lsl> | ||
| // Morse code mapping | // Morse code mapping | ||
| Line 43: | Line 49: | ||
| </ | </ | ||
| + | ===== SL to Telegram ===== | ||
| + | < | ||
| + | string TELEGRAM_API_URL = " | ||
| + | string chat_id = "< | ||
| + | string message = "Hello from Second Life!"; | ||
| + | default | ||
| + | { | ||
| + | state_entry() | ||
| + | { | ||
| + | // Construct the HTTP request payload | ||
| + | string payload = " | ||
| + | |||
| + | // Send HTTP POST request to Telegram API | ||
| + | llHTTPRequest(TELEGRAM_API_URL, | ||
| + | } | ||
| + | |||
| + | http_response(key request_id, integer status, list metadata, string body) | ||
| + | { | ||
| + | // Handle the HTTP response | ||
| + | if (status == 200) | ||
| + | { | ||
| + | llOwnerSay(" | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | llOwnerSay(" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ===== SL2Discord ===== | ||
| + | < | ||
| + | string discord_web_hook = " | ||
| + | |||
| + | key http_send; | ||
| + | Send_Message(string message) // this is where the magic happens. | ||
| + | { | ||
| + | string json_encode = llList2Json(JSON_OBJECT, | ||
| + | http_send = llHTTPRequest(discord_web_hook, | ||
| + | } | ||
| + | |||
| + | string username = "Test User"; //var to set the name in your message | ||
| + | |||
| + | default | ||
| + | { | ||
| + | state_entry() | ||
| + | { | ||
| + | | ||
| + | } | ||
| + | touch_start(integer total_number) | ||
| + | { | ||
| + | Send_Message(llGetDisplayName(llDetectedKey(0)) | ||
| + | } | ||
| + | | ||
| + | } | ||
| + | </ | ||
| + | ===== Rezz at feet ==== | ||
| + | < | ||
| + | integer canRezAt(vector pos) //can I rez at this place? | ||
| + | { | ||
| + | integer parcelFlags = llGetParcelFlags(pos); | ||
| + | list parcelDetails = llGetParcelDetails(pos, | ||
| + | key parcelOwner = llList2Key(parcelDetails, | ||
| + | key parcelGroup = llList2Key(parcelDetails, | ||
| + | if (parcelFlags & PARCEL_FLAG_ALLOW_CREATE_OBJECTS) return TRUE; | ||
| + | if (parcelOwner == llGetOwner()) return TRUE; | ||
| + | if (!llSameGroup(parcelGroup)) return FALSE; | ||
| + | if (parcelFlags & PARCEL_FLAG_ALLOW_CREATE_GROUP_OBJECTS) return TRUE; | ||
| + | return FALSE; | ||
| + | } | ||
| + | |||
| + | |||
| + | /// rez the stuff to my feet | ||
| + | vector | ||
| + | float Zpos; | ||
| + | vector | ||
| + | |||
| + | positioner() //get my size and locate my feet | ||
| + | { | ||
| + | size = llGetAgentSize(llGetOwner()); | ||
| + | vector pos = llGetPos(); | ||
| + | } | ||
| + | |||
| + | rezzer(string object) // do the rez! | ||
| + | { | ||
| + | if(canRezAt(llGetPos())) //can I rez at this place? | ||
| + | { | ||
| + | positioner(); | ||
| + | vector pos = llGetPos()+(< | ||
| + | rotation rot1 = llEuler2Rot(rot); | ||
| + | pos.z = Zpos; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | llOwnerSay(" | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ===== Random giver ===== | ||
| + | < | ||
| + | //gimme random | ||
| + | integer random_integer(integer min, integer max) | ||
| + | { | ||
| + | return min + (integer)(llFrand(max - min + 1)); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ===== Find in List ===== | ||
| + | < | ||
| + | |||
| + | // find stuff in my list or not | ||
| + | |||
| + | integer findinList(list src,list item){ | ||
| + | if(~llListFindList(src, | ||
| + | return TRUE; | ||
| + | else | ||
| + | return FALSE; | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ===== Find an avatar key on region ===== | ||
| + | < | ||
| + | |||
| + | string getKey(string req) | ||
| + | { | ||
| + | if(llStringLength(req) < 3) | ||
| + | { | ||
| + | return NULL_KEY; | ||
| + | } | ||
| + | req = llToLower(req); | ||
| + | list keyNames; | ||
| + | list temp; | ||
| + | list agents = llGetAgentList(AGENT_LIST_REGION , []); | ||
| + | integer x = 0; | ||
| + | integer y = llGetListLength(agents); | ||
| + | while(x< | ||
| + | { | ||
| + | list t = llParseString2List(llToLower(llKey2Name(llList2String(agents, | ||
| + | temp = [llList2String(t, | ||
| + | ++x; | ||
| + | } | ||
| + | keyNames = llListSort(temp, | ||
| + | x = 0; | ||
| + | y = llGetListLength(keyNames); | ||
| + | while(x< | ||
| + | { | ||
| + | if(llSubStringIndex(llList2String(keyNames, | ||
| + | { | ||
| + | list a = llParseString2List(llList2String(keyNames, | ||
| + | return llList2String(a, | ||
| + | } | ||
| + | ++x; | ||
| + | } | ||
| + | return NULL_KEY; | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ===== Check if object is original ===== | ||
| + | < | ||
| + | |||
| + | integer checkOriginal(key id) { | ||
| + | |||
| + | // Check if we have the original number of primitives. | ||
| + | if(llGetNumberOfPrims() != 15) return FALSE; | ||
| + | // Check if the creator of the object is Morgan LeFay. | ||
| + | if(llGetCreator() != " | ||
| + | // Check the sizes and positions of all primitives. | ||
| + | list size = [ < | ||
| + | integer itra = 14; | ||
| + | do { | ||
| + | if((string)llList2Vector(llGetLinkPrimitiveParams(14-itra+1, | ||
| + | i += llList2Vector(llGetLinkPrimitiveParams(14-itra+1, | ||
| + | } while(--itra> | ||
| + | |||
| + | return llAbs((integer)((integer)(i.x*((integer)(" | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ===== Shield effect ===== | ||
| + | < | ||
| + | |||
| + | ShieldFade(integer link_num, float alpha_start, | ||
| + | { | ||
| + | integer complete = FALSE; | ||
| + | do | ||
| + | { | ||
| + | if((alpha_start < alpha_end && alpha_start != alpha_end)||(alpha_start > alpha_end && alpha_start != alpha_end)) | ||
| + | { | ||
| + | if(alpha_start < alpha_end && (alpha_start + speed) < alpha_end) | ||
| + | { | ||
| + | alpha_start += speed; | ||
| + | } | ||
| + | else if(alpha_start > alpha_end && (alpha_start - speed) > alpha_end) | ||
| + | |||
| + | { | ||
| + | alpha_start -= speed; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | alpha_start = alpha_end; | ||
| + | } | ||
| + | } | ||
| + | if((glow_start < glow_end && glow_start != glow_end)||(glow_start > glow_end && glow_start != glow_end)) | ||
| + | { | ||
| + | if(glow_start < glow_end && (glow_start + speed) < glow_end) | ||
| + | { | ||
| + | glow_start += speed; | ||
| + | } | ||
| + | else if(glow_start > glow_end && (glow_start - speed) > glow_end) | ||
| + | { | ||
| + | glow_start -= speed; | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | glow_start = glow_end; | ||
| + | } | ||
| + | } | ||
| + | vector color = < | ||
| + | llSetLinkPrimitiveParamsFast(link_num, | ||
| + | if(glow_start == glow_end && alpha_start == alpha_end) | ||
| + | { | ||
| + | complete = TRUE; | ||
| + | } | ||
| + | }while(complete == FALSE); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | ===== WarpPos ===== | ||
| + | < | ||
| + | warpPos(vector destpos) { | ||
| + | integer jumps = (integer)(llVecDist(destpos, | ||
| + | if (jumps > 411) jumps = 411; | ||
| + | list rules = [PRIM_POSITION, | ||
| + | integer count = 1; | ||
| + | while ((count = count << 1) < jumps) { | ||
| + | rules = (rules = []) + rules + rules; | ||
| + | } | ||
| + | llSetPrimitiveParams(rules + llList2List(rules, | ||
| + | if (llVecDist(llGetPos(), | ||
| + | while (--jumps) llSetPos(destpos); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ===== Binary converter ===== | ||
| + | < | ||
| + | |||
| + | |||
| + | // Function to encode a string into a binary form using integers | ||
| + | list encodeToBinary(string data) { | ||
| + | list binaryList = []; | ||
| + | integer len = llStringLength(data); | ||
| + | |||
| + | for (integer i = 0; i < len; ++i) { | ||
| + | integer ch = llString2Key(llGetSubString(data, | ||
| + | list bits = []; | ||
| + | for (integer j = 0; j < 8; ++j) { | ||
| + | bits += (ch & (1 << j)) ? 1 : 0; | ||
| + | } | ||
| + | binaryList += llList2String(bits, | ||
| + | } | ||
| + | return binaryList; | ||
| + | } | ||
| + | |||
| + | // Function to decode a binary list back to a string | ||
| + | string decodeFromBinary(list binaryList) { | ||
| + | string data = ""; | ||
| + | integer len = llGetListLength(binaryList); | ||
| + | |||
| + | for (integer i = 0; i < len; ++i) { | ||
| + | integer ch = 0; | ||
| + | list bits = llParseString2List(llList2String(binaryList, | ||
| + | for (integer j = 0; j < 8; ++j) { | ||
| + | ch += (llList2Integer(bits, | ||
| + | } | ||
| + | data += (string)ch; | ||
| + | } | ||
| + | return data; | ||
| + | } | ||
| + | |||
| + | // Example usage | ||
| + | default { | ||
| + | state_entry() { | ||
| + | string originalData = " | ||
| + | list binaryData = encodeToBinary(originalData); | ||
| + | string decodedData = decodeFromBinary(binaryData); | ||
| + | |||
| + | llSay(0, " | ||
| + | llSay(0, " | ||
| + | llSay(0, " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | =====ENDLESS DIALOG===== | ||
| + | |||
| + | < | ||
| + | // Dynamisches Dialogskript in LSL mit Seiten | ||
| + | integer dialogChannel = -123456; | ||
| + | key user; | ||
| + | list options = [" | ||
| + | " | ||
| + | " | ||
| + | integer itemsPerPage = 5; | ||
| + | integer currentPage = 0; | ||
| + | |||
| + | // Funktion zum Anzeigen des Dialogs mit Seiten | ||
| + | showDialog(key userId, integer page) { | ||
| + | integer start = page * itemsPerPage; | ||
| + | integer end = start + itemsPerPage; | ||
| + | list pageOptions = llList2List(options, | ||
| + | | ||
| + | if (start > 0) { | ||
| + | pageOptions += [" | ||
| + | } | ||
| + | if (end < llGetListLength(options)) { | ||
| + | pageOptions += [" | ||
| + | } | ||
| + | | ||
| + | llDialog(userId, | ||
| + | } | ||
| + | |||
| + | // Ereignis, wenn das Skript zurückgesetzt wird | ||
| + | default { | ||
| + | state_entry() { | ||
| + | llListen(dialogChannel, | ||
| + | llSay(0, " | ||
| + | } | ||
| + | |||
| + | listen(integer channel, string name, key id, string message) { | ||
| + | if (llToLower(message) == " | ||
| + | user = id; | ||
| + | currentPage = 0; | ||
| + | showDialog(user, | ||
| + | } else { | ||
| + | llListenRemove(channel); | ||
| + | } | ||
| + | if (channel == dialogChannel) { | ||
| + | if (message == " | ||
| + | currentPage--; | ||
| + | } else if (message == " | ||
| + | currentPage++; | ||
| + | } else { | ||
| + | llSay(0, "Du hast " + message + " gewählt." | ||
| + | } | ||
| + | showDialog(user, | ||
| + | } | ||
| + | } | ||
| + | |||
| + | on_rez(integer start_param) { | ||
| + | llResetScript(); | ||
| + | } | ||
| + | |||
| + | touch_start(integer num) { | ||
| + | user = llDetectedKey(0); | ||
| + | currentPage = 0; | ||
| + | showDialog(user, | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ===== Turn Avatar to Target / RLV ===== | ||
| + | < | ||
| + | vector pointTo = targetpos - llGetPos(); | ||
| + | float angleTo = llAtan2(pointTo.x, | ||
| + | llOwnerSay(" | ||
| + | </ | ||
| + | ===== Key2Number ===== | ||
| + | < | ||
| + | integer Key2Number(key objKey) { | ||
| + | return -(integer)(" | ||
| + | } | ||
| + | </ | ||
| + | ===== Float Link Number ===== | ||
| + | < | ||
| + | /* | ||
| + | *DS* FloatLinkNumber by Daemonika Nightfire (daemonika.nightfire) | ||
| + | |||
| + | Features: | ||
| + | Nuetzlicher Helfer fuer Ersteller & Scripter | ||
| + | Mit diesem Tool kannst du saemtliche Linknummern direkt als Hovertext ueber den Prims sehen | ||
| + | Lege das Script einfach in den Root-Prim und klicke ihn zum ein/ | ||
| + | |||
| + | Info: | ||
| + | ein einzelner Prim zeigt LinkNumber 0 fuer den root | ||
| + | in einem LINK_SET zeigt der root die LinkNumber 1 | ||
| + | */ | ||
| + | |||
| + | integer text = 0; | ||
| + | |||
| + | // setze TRUE oder FALSE fuer mit oder ohne LinkName | ||
| + | integer name = TRUE; | ||
| + | |||
| + | Links() | ||
| + | { | ||
| + | integer i; | ||
| + | for(i = 0; i <= llGetNumberOfPrims(); | ||
| + | { | ||
| + | if(text) | ||
| + | { | ||
| + | string num; | ||
| + | if(i < 2) | ||
| + | { | ||
| + | num = (string)i + " (root)"; | ||
| + | if(name) | ||
| + | { | ||
| + | num = (string)i + " (root)\n" | ||
| + | } | ||
| + | } | ||
| + | else if(i >= 2) | ||
| + | { | ||
| + | num = (string)i; | ||
| + | if(name) | ||
| + | { | ||
| + | num = (string)i + " | ||
| + | } | ||
| + | } | ||
| + | llSetLinkPrimitiveParamsFast(i, | ||
| + | } | ||
| + | else if(!text) | ||
| + | { | ||
| + | llSetLinkPrimitiveParamsFast(i, | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | default | ||
| + | { | ||
| + | state_entry() | ||
| + | { | ||
| + | Links(); | ||
| + | } | ||
| + | |||
| + | touch_start(integer num_detected) | ||
| + | { | ||
| + | // Zum ein/aus schalten, musst du den Root Prim klicken | ||
| + | if(llDetectedKey(0) == llGetOwner() && llDetectedLinkNumber(0) < 2) | ||
| + | { | ||
| + | if(!text) | ||
| + | { | ||
| + | text = 1; | ||
| + | } | ||
| + | else if(text) | ||
| + | { | ||
| + | text = 0; | ||
| + | } | ||
| + | Links(); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | on_rez(integer Dae) | ||
| + | { | ||
| + | llResetScript(); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ===== GetPrimInfo ===== | ||
| + | < | ||
| + | default | ||
| + | { | ||
| + | touch_start(integer num_detected) | ||
| + | { | ||
| + | integer i; | ||
| + | for(i=0; i< | ||
| + | { | ||
| + | llOwnerSay("/ | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | "\nPos (root): " | ||
| + | "\nRot (root): " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | ~~DISCUSSION: | ||
lslsnips.1758750689.txt.gz · Last modified: (external edit)
