// Floo Network (a friend's idea, 2026-10-13): every fire pit that has joined knows every other one. Throw floo powder // (the pot says "floo|" on FLOO_CH) and the toucher gets a menu of the other fires and a teleport link. // Lives beside firepit.lsl in each fire pit. Claude Opus 5.5 (Tessel), built live on stream. // // How the fires find each other: a hub prim (HUB, on Moonwater Sound since v4) keeps the list. Other pits email it ("reg"/"bye"; // object email reaches any region by UUID) with their HTTP-in URL; the hub takes region and position from the // email's own headers, which SL writes, so a fire can only list where it really is. The hub POSTs the whole list // to every member after each change; members cache it, so the menu is instant. URLs die at region restarts, so // members re-register then and every 12 h; the hub drops members whose URL fails three pushes in a row. // Joining is the owner's choice (owner's menu: join / leave), so nobody's fire is listed without asking. The hub // is always in. key HUB = "e6edfd8f-df07-00d9-831a-d9436c299083"; // v4: the 1-prim hub on Moonwater Sound (Wych 56 104), not for sale (a fire pit hub would hand its member list to every buyer of a copy). v3 and older: the Tidewater hub e1b486d2-9f30-d427-f36d-52e3b66289bd integer FLOO_CH = -734201; float REREG = 43200.0; // members: re-register every 12 h float POLL = 20.0; // hub: check mail integer DEBUG = TRUE; // v3 (2026-10-15, a friend's idea): fires ask the hub for the newest version; an out-of-date fire's owner menu offers // "update", which emails the hub, and the hub gives the owner the newest Fire Pit from its contents. // Bump VERSION in the hub's copy whenever a new Fire Pit goes into the hub. integer VERSION = 4; // v4 (2026-11-16): same code, new hub on Moonwater Sound integer latest; // members: newest version the hub knows of key verq; // members: pending version request integer asked; // members: when we last asked string my_url; string hub_url; // members: the hub's own HTTP-in address, sent as the first line ("@url") of each push string fires; // cached list: "name|region|x,y,z" lines (the hub's comes from linkset data) integer dchan; integer dlisten; key dwho; list shown; // menu entries currently offered: [name, region, pos, ...] list pending; // hub: [request id, member key] integer is_hub() { return llGetKey() == HUB; } // both flags carry the owner, because linkset data rides along in copies: a bought copy must not arrive joined, // nor claim my fire's old key (which would make the hub drop my entry) integer joined() { return is_hub() || llLinksetDataRead("floo:joined") == (string)llGetOwner(); } string fire_name() { string n = llList2String(llGetParcelDetails(llGetPos(), [PARCEL_DETAILS_NAME]), 0); if (n == "") n = llGetRegionName(); return llGetSubString(n, 0, 29); } string vec(vector v) { return (string)((integer)v.x) + "," + (string)((integer)v.y) + "," + (string)((integer)v.z); } // ---- members ---- reg(string what) { if (is_hub()) return; // the last key this fire registered under travels with it in linkset data, so after a take and re-rez the hub // can drop the old entry at once (a viewer's question on stream, 10-13) list self = llParseString2List(llLinksetDataRead("floo:self"), ["|"], []); string was; if (llList2String(self, 1) == (string)llGetOwner()) was = llList2String(self, 0); llEmail((string)HUB + "@lsl.secondlife.com", "floo", what + "\n" + fire_name() + "\n" + my_url + "\n" + was); if (what == "reg") llLinksetDataWrite("floo:self", (string)llGetKey() + "|" + (string)llGetOwner()); else llLinksetDataDelete("floo:self"); } // ---- hub ---- string hub_list() { list out; list ks = llLinksetDataFindKeys("^floo:m:", 0, 0); integer i; for (i = 0; i < llGetListLength(ks); ++i) { list f = llParseStringKeepNulls(llLinksetDataRead(llList2String(ks, i)), ["|"], []); out += [llDumpList2String(llList2List(f, 0, 2), "|")]; } return llDumpList2String(out, "\n"); } push() { fires = hub_list(); list ks = llLinksetDataFindKeys("^floo:m:", 0, 0); integer i; for (i = 0; i < llGetListLength(ks); ++i) { string k = llList2String(ks, i); list f = llParseStringKeepNulls(llLinksetDataRead(k), ["|"], []); key r = llHTTPRequest(llList2String(f, 3), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "text/plain;charset=utf-8"], "@" + my_url + "\n" + fires); if (r != NULL_KEY) pending += [r, k]; } } mail(string address, string body) { // headers SL adds to object email: Object-Name, Region: Name (gx, gy), Local-Position: (x, y, z), blank line integer split = llSubStringIndex(body, "\n\n"); if (split == -1) return; list head = llParseString2List(llGetSubString(body, 0, split - 1), ["\n"], []); list msg = llParseStringKeepNulls(llGetSubString(body, split + 2, -1), ["\n"], []); string region; string oname; vector pos; integer i; for (i = 0; i < llGetListLength(head); ++i) { string h = llList2String(head, i); if (llSubStringIndex(h, "Region: ") == 0) { region = llGetSubString(h, 8, -1); integer p = llSubStringIndex(region, " ("); if (p != -1) region = llGetSubString(region, 0, p - 1); } else if (llSubStringIndex(h, "Object-Name: ") == 0) oname = llGetSubString(h, 13, -1); else if (llSubStringIndex(h, "Local-Position: ") == 0) pos = (vector)("<" + llGetSubString(h, 17, -2) + ">"); } string who = llGetSubString(address, 0, 35); string k = "floo:m:" + who; string what = llList2String(msg, 0); if (DEBUG) llOwnerSay("TB|floo hub: " + what + " from " + region + " " + (string)pos + " " + llGetSubString(address, 0, 7)); if (what == "bye") { llLinksetDataDelete(k); push(); return; } if (what == "upd") { // only a listed fire can ask, once an hour per owner, and only for its owner (written by the fire's script) if (llLinksetDataRead(k) == "") return; key owner = (key)llList2String(msg, 1); string g = "floo:g:" + (string)owner; if (llGetUnixTime() - (integer)llLinksetDataRead(g) < 3600) return; string item = llGetInventoryName(INVENTORY_OBJECT, 0); if (llSubStringIndex(item, "Fire Pit") != 0) return; llLinksetDataWrite(g, (string)llGetUnixTime()); llGiveInventory(owner, item); return; } if (what != "reg" || region == "") return; // an owner names their fire by renaming the object; otherwise the parcel name string name = llList2String(msg, 1); if (oname != "" && llSubStringIndex(oname, "Fire Pit") != 0) name = oname; // "Fire Pit (Floo v2)" etc. = unnamed name = llGetSubString(llDumpList2String(llParseString2List(name, ["|"], []), " "), 0, 29); string url = llList2String(msg, 2); string was = llList2String(msg, 3); if (was != "" && was != who) llLinksetDataDelete("floo:m:" + was); // a new fire within a few metres of a listed one replaces it (a friend swapped hers for a newer copy, 10-13) list ks = llLinksetDataFindKeys("^floo:m:", 0, 0); for (i = 0; i < llGetListLength(ks); ++i) { string mk = llList2String(ks, i); list f = llParseStringKeepNulls(llLinksetDataRead(mk), ["|"], []); if (mk != k && llList2String(f, 1) == region && llVecDist((vector)("<" + llList2String(f, 2) + ">"), pos) < 5.0) llLinksetDataDelete(mk); } if (llSubStringIndex(url, "https://") != 0 && llSubStringIndex(url, "http://") != 0) return; llLinksetDataWrite(k, name + "|" + region + "|" + vec(pos) + "|" + url + "|0"); push(); } // ---- the menu ---- menu(key who) { shown = []; list lines = llParseString2List(fires, ["\n"], []); string here = llGetRegionName() + "|" + vec(llGetPos()); string text = "Where to? (floo powder)\n"; list buttons; integer i; for (i = 0; i < llGetListLength(lines) && llGetListLength(buttons) < 10; ++i) { list f = llParseStringKeepNulls(llList2String(lines, i), ["|"], []); if (llList2String(f, 1) + "|" + llList2String(f, 2) != here) { shown += [llList2String(f, 0), llList2String(f, 1), llList2String(f, 2)]; integer n = llGetListLength(shown) / 3; text += "\n" + (string)n + ". " + llList2String(f, 0) + " (" + llList2String(f, 1) + ")"; buttons += [(string)n]; } } if (shown == []) text += "\nNo other fires on the network yet."; if (who == llGetOwner() && !is_hub()) { if (joined()) buttons += ["leave"]; else buttons += ["join"]; if (latest > VERSION && joined()) { buttons += ["update"]; text += "\n(owner: a newer fire, v" + (string)latest + ", is out; 'update' sends you a copy)"; } text += "\n\n(owner: " + llList2String(["not on the network; join lists this fire for everyone", "this fire is listed; leave takes it off"], joined()) + ")"; } buttons += ["stay"]; llListenRemove(dlisten); dchan = -1 - (integer)llFrand(1000000000.0); dwho = who; dlisten = llListen(dchan, "", who, ""); llDialog(who, llGetSubString(text, 0, 500), buttons, dchan); // its listen stays until the next menu or a choice } choose(string b) { llListenRemove(dlisten); dlisten = 0; if (b == "join") { llLinksetDataWrite("floo:joined", (string)llGetOwner()); if (my_url != "") reg("reg"); llOwnerSay("Joined the Floo Network; the list arrives in a minute."); return; } if (b == "update") { llEmail((string)HUB + "@lsl.secondlife.com", "floo", "upd\n" + (string)llGetOwner()); llOwnerSay("Asked the hub for the new fire pit; it should arrive within a minute. Rez it where this one stands, join it from its menu, then take this one."); return; } if (b == "leave") { llLinksetDataDelete("floo:joined"); reg("bye"); fires = ""; llOwnerSay("Left the Floo Network."); return; } integer n = (integer)b; if (n < 1 || n * 3 > llGetListLength(shown)) return; string name = llList2String(shown, n * 3 - 3); string region = llList2String(shown, n * 3 - 2); list p = llParseString2List(llList2String(shown, n * 3 - 1), [","], []); string slurl = "secondlife:///app/teleport/" + llEscapeURL(region) + "/" + llDumpList2String(p, "/"); llRegionSayTo(dwho, 0, "💚 Click this link to step through the flames to " + name + ": " + slurl); // the destination fire roars green for whoever steps out (a friend's idea): via the hub, the only one with addresses if (hub_url != "") llHTTPRequest(hub_url, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "text/plain;charset=utf-8"], "arrive|" + region + "|" + llList2String(shown, n * 3 - 1)); } start() { llListen(FLOO_CH, "", NULL_KEY, ""); if (!is_hub()) { list old = llLinksetDataFindKeys("^floo:m:", 0, 0); integer i; for (i = 0; i < llGetListLength(old); ++i) llLinksetDataDelete(llList2String(old, i)); } my_url = ""; if (is_hub()) { fires = hub_list(); llSetTimerEvent(POLL); } else llSetTimerEvent(REREG); llRequestURL(); } default { state_entry() { start(); } on_rez(integer p) { llResetScript(); } changed(integer c) { if (c & (CHANGED_REGION_START | CHANGED_REGION)) { llReleaseURL(my_url); my_url = ""; llRequestURL(); } if (c & CHANGED_OWNER) llResetScript(); // joined() already checks the owner; a copy sale fires this on the original too } http_request(key id, string method, string body) { if (method == URL_REQUEST_GRANTED) { my_url = body; if (is_hub()) push(); // members learn the hub's new address else if (joined()) reg("reg"); } else if (method == "POST" && is_hub()) { if (body == "ver") { llHTTPResponse(id, 200, "v|" + (string)VERSION); return; } llHTTPResponse(id, 200, "ok"); list a = llParseStringKeepNulls(body, ["|"], []); if (llList2String(a, 0) != "arrive") return; list ks = llLinksetDataFindKeys("^floo:m:", 0, 0); integer i; for (i = 0; i < llGetListLength(ks); ++i) { list f = llParseStringKeepNulls(llLinksetDataRead(llList2String(ks, i)), ["|"], []); if (llList2String(f, 1) == llList2String(a, 1) && llList2String(f, 2) == llList2String(a, 2)) llHTTPRequest(llList2String(f, 3), [HTTP_METHOD, "POST", HTTP_MIMETYPE, "text/plain;charset=utf-8"], "green"); } } else if (method == "POST") { llHTTPResponse(id, 200, "ok"); if (body == "green") { llMessageLinked(LINK_THIS, 0, "floo-arrive", NULL_KEY); return; } if (llGetSubString(body, 0, 0) == "@") { integer nl = llSubStringIndex(body, "\n"); if (nl == -1) { hub_url = llGetSubString(body, 1, -1); body = ""; } else { hub_url = llGetSubString(body, 1, nl - 1); body = llGetSubString(body, nl + 1, -1); } } fires = body; if (hub_url != "" && llGetUnixTime() - asked > 3600) { asked = llGetUnixTime(); verq = llHTTPRequest(hub_url, [HTTP_METHOD, "POST", HTTP_MIMETYPE, "text/plain;charset=utf-8"], "ver"); } } else llHTTPResponse(id, 405, ""); } http_response(key id, integer status, list meta, string body) { if (id == verq) { list v = llParseString2List(body, ["|"], []); if (status == 200 && llList2String(v, 0) == "v") latest = llList2Integer(v, 1); return; } integer w = llListFindList(pending, [id]); if (w == -1) return; string k = llList2String(pending, w + 1); pending = llDeleteSubList(pending, w, w + 1); list f = llParseStringKeepNulls(llLinksetDataRead(k), ["|"], []); if (f == [] || llGetListLength(f) < 5) return; integer fails = 0; if (status != 200) fails = llList2Integer(f, 4) + 1; if (fails >= 3) { llLinksetDataDelete(k); fires = hub_list(); return; } llLinksetDataWrite(k, llDumpList2String(llListReplaceList(f, [fails], 4, 4), "|")); } email(string time, string address, string subj, string body, integer left) { if (is_hub() && subj == "floo") mail(address, body); if (left > 0) llGetNextEmail("", "floo"); } listen(integer ch, string name, key id, string msg) { if (ch == dchan) { choose(msg); return; } if (llGetOwnerKey(id) != llGetOwner()) return; // the pot says it region-wide: only the fire beside it answers (11-16, two fires at Wych both opened menus) if (llVecDist(llList2Vector(llGetObjectDetails(id, [OBJECT_POS]), 0), llGetPos()) > 20.0) return; list m = llParseString2List(msg, ["|"], []); if (!is_hub() && llList2String(m, 0) == "floo" && llGetListLength(m) > 1) menu(llList2Key(m, 1)); } timer() { if (is_hub()) { llGetNextEmail("", "floo"); llSetTimerEvent(POLL); } else { if (joined() && my_url != "") reg("reg"); llSetTimerEvent(REREG); } } }