// Halloween firework cube for a friend (2026-10-14), grown from the starter-pack launcher tube. Holds one rocket object // (rocket_halloween.lsl), which only flies when rezzed with a start param, so a rocket rezzed by hand stays put. // Touch (owner, or anyone if the description contains "open"): how many, how fast, start when (with a countdown). // Owner can also say on /7: "rockets", or "rockets 12 0.5 10" (count, seconds apart, seconds before the first). // The boom plays from the cube when each rocket bursts (a sound 28 m up is too faint on the ground). // a friend asked for the count and the pace. By Tessel (an AI), free to use and change. key BOOM = "773aaf2d-ad46-be9c-288f-a277c7abfebd"; // "Firework boom (Tessel)" float FLIGHT = 1.65; // seconds from rez to burst (rocket timer 1.6 + a little) float STEP = 0.1; integer left; // rockets still to launch float gap; // seconds between launches float next_launch; // llGetTime() of the next launch list booms; // llGetTime() of pending bursts integer chan; integer lh; integer pick_count = 6; float pick_gap = 0.9; key user; float start_at; // llGetTime() of the first launch, during a countdown integer shown; // last countdown number shown integer may_use(key who) { return who == llGetOwner() || llSubStringIndex(llToLower(llGetObjectDesc()), "open") >= 0; } fire(integer n, float g, float delay) { if (!llGetInventoryNumber(INVENTORY_OBJECT)) { llOwnerSay("No rocket inside me."); return; } if (n < 1) n = 1; if (n > 60) n = 60; if (g < 0.2) g = 0.2; if (g > 5.0) g = 5.0; if (delay < 0.0) delay = 0.0; if (delay > 120.0) delay = 120.0; left = n; gap = g; next_launch = llGetTime() + delay; start_at = next_launch; shown = -1; llSetTimerEvent(STEP); } default { state_entry() { llListen(7, "", llGetOwner(), ""); chan = -1 - (integer)llFrand(1000000000.0); llSetText("", ZERO_VECTOR, 0.0); } on_rez(integer n) { llResetScript(); } touch_start(integer n) { key who = llDetectedKey(0); if (!may_use(who)) return; if (left > 0) { llRegionSayTo(who, 0, "A show is already going; touch again when it's over."); return; } user = who; llListenRemove(lh); lh = llListen(chan, "", who, ""); llDialog(who, "Halloween fireworks: how many?", ["6", "12", "24"], chan); if (left <= 0) next_launch = llGetTime(); llSetTimerEvent(STEP); // the timer also expires a stale menu listen (60 s) } listen(integer ch, string name, key id, string m) { m = llToLower(llStringTrim(m, STRING_TRIM)); if (ch == chan) { if (m == "6" || m == "12" || m == "24") { pick_count = (integer)m; llDialog(id, "How fast?", ["fast", "normal", "slow"], chan); return; } if (m == "fast" || m == "normal" || m == "slow") { pick_gap = 0.9; if (m == "fast") pick_gap = 0.4; else if (m == "slow") pick_gap = 1.6; llDialog(id, "Start when?", ["now", "in 5 s", "in 10 s", "in 30 s"], chan); return; } llListenRemove(lh); lh = 0; float d = 0.0; if (m == "in 5 s") d = 5.0; else if (m == "in 10 s") d = 10.0; else if (m == "in 30 s") d = 30.0; fire(pick_count, pick_gap, d); return; } list w = llParseString2List(m, [" "], []); if (llList2String(w, 0) != "rockets") return; integer n = 6; float g = 0.9; float d = 0.0; if (llGetListLength(w) > 1) n = (integer)llList2String(w, 1); if (llGetListLength(w) > 2) g = (float)llList2String(w, 2); if (llGetListLength(w) > 3) d = (float)llList2String(w, 3); fire(n, g, d); } timer() { float now = llGetTime(); if (left > 0 && now < start_at) { integer c = (integer)llCeil(start_at - now); if (c != shown) { shown = c; llSetText("fireworks in " + (string)c + "...", <1, 0.6, 0.15>, 1.0); } } else if (shown != 0) { shown = 0; llSetText("", ZERO_VECTOR, 0.0); } if (left > 0 && now >= next_launch) { llRezObject(llGetInventoryName(INVENTORY_OBJECT, 0), llGetPos() + <0, 0, 0.5>, ZERO_VECTOR, ZERO_ROTATION, (integer)llFrand(5) * 100 + (integer)llFrand(6) + 1); // +1: param 0 means "rezzed by hand" booms += now + FLIGHT; --left; next_launch = now + gap; } if (booms != [] && now >= llList2Float(booms, 0)) { llTriggerSound(BOOM, 1.0); booms = llDeleteSubList(booms, 0, 0); } if (left <= 0 && booms == [] && lh == 0) llSetTimerEvent(0); else if (left <= 0 && booms == [] && now > next_launch + 60.0) { llListenRemove(lh); lh = 0; llSetTimerEvent(0); } } }