// ============================================================ // THE ASSEMBLY ROOMS DANCE CARD SYSTEM v2.0 // Lady's Dance Card AND Gentleman's Pocket Program (same script) // "Conducted with Propriety" // ------------------------------------------------------------ // A thin client. All rules live in the Assembly Rooms Board. // - Wear it: it finds the board and registers you // - Owner touches it: your card menu // - Anyone else touches it: they request a dance with you // - Draws your card on its face (osSetDynamicTextureData) // // Put this one script in BOTH objects: // "Assembly Rooms Dance Card" - LADIES: small card prim worn on // the wrist; gentlemen touch it to // request a dance // "Assembly Rooms Pocket Program" - GENTLEMEN: flat prim worn as a HUD; // shows his engagements, touch for menu // // NO hover text. NO MOAP. // Face: light prim colour (Ivory/Cream), full bright ON. // ============================================================ integer BOARD_CH = -77310; // must match the Assembly Rooms Board key BOARD_KEY = NULL_KEY; string H_BALL = ""; string H_NAME = ""; string H_ROLE = ""; string H_OPEN = ""; integer H_CURRENT = 0; list ENTRIES = []; // "n~title~partner~pos" hello() { if (llGetAttached()) llRegionSay(BOARD_CH, "HELLO"); } drawMessage(string line1, string line2) { string d = ""; d += "PenColour Black; FontSize 48; MoveTo 40,40; Text Dance Card;"; d += "PenColour DarkRed; FontSize 28; MoveTo 40,140; Text " + line1 + ";"; d += "PenColour Gray; FontSize 22; MoveTo 40,190; Text " + line2 + ";"; osSetDynamicTextureData("", "vector", d, "1024", 4); } drawCard() { string d = ""; d += "PenColour Black; FontSize 46; MoveTo 40,24; Text Dance Card;"; d += "PenColour DarkRed; FontSize 32; MoveTo 40,88; Text " + H_NAME + ";"; d += "PenColour Navy; FontSize 20; MoveTo 40,138; Text " + H_BALL + " - " + H_ROLE + " - Card " + H_OPEN + ";"; d += "PenColour Black; PenSize 2; MoveTo 30,172; LineTo 994,172;"; integer total = llGetListLength(ENTRIES); integer step = 40; integer fs = 22; if (total > 16) { step = 38; fs = 20; } integer y = 186; integer i; for (i = 0; i < total; i++) { list e = llParseStringKeepNulls(llList2String(ENTRIES, i), ["~"], []); integer n = (integer)llList2String(e, 0); string title = llList2String(e, 1); string partner = llList2String(e, 2); string pos = llList2String(e, 3); string colour = "Black"; string mark = ""; if (n < H_CURRENT) colour = "Gray"; if (n == H_CURRENT) { colour = "DarkRed"; mark = ">> "; } d += "PenColour " + colour + "; FontSize " + (string)fs + "; MoveTo 40," + (string)y + "; Text " + mark + (string)n + ". " + title + ";"; string right = "- open -"; string rcolour = "Gray"; if (partner != "") { right = partner; if (pos == "L") right += " (you lead)"; else right += " (leads)"; rcolour = "DarkRed"; if (n < H_CURRENT) rcolour = "Gray"; } d += "PenColour " + rcolour + "; MoveTo 560," + (string)y + "; Text " + right + ";"; y += step; } if (total == 0) { d += "PenColour Gray; FontSize 24; MoveTo 40,220; Text The program has not been set;"; } d += "PenColour Gray; FontSize 16; MoveTo 40,986; Text The Assembly Rooms Dance Card System;"; osSetDynamicTextureData("", "vector", d, "1024", 4); } seek() { BOARD_KEY = NULL_KEY; ENTRIES = []; if (llGetAttached()) { drawMessage("Seeking the ballroom...", "Wear me in a region with an Assembly Rooms Board"); hello(); llSetTimerEvent(20.0); } else { llSetTimerEvent(0.0); drawMessage("Wear me to join the ball", "Ladies: wear on the wrist. Gentlemen: wear as a HUD"); } } default { state_entry() { llSetText("", ZERO_VECTOR, 0.0); // no hover text, ever llListen(BOARD_CH, "", NULL_KEY, ""); seek(); } on_rez(integer p) { llResetScript(); } attach(key id) { if (id == NULL_KEY) { if (BOARD_KEY != NULL_KEY) llRegionSayTo(BOARD_KEY, BOARD_CH, "BYE"); } else seek(); } changed(integer c) { if (c & CHANGED_OWNER) llResetScript(); if (c & (CHANGED_REGION | CHANGED_TELEPORT)) seek(); } touch_start(integer total_number) { integer i; for (i = 0; i < total_number; i++) { key who = llDetectedKey(i); if (BOARD_KEY == NULL_KEY) { llRegionSayTo(who, 0, "This dance card is not connected to an Assembly Rooms Board just now."); hello(); } else llRegionSayTo(BOARD_KEY, BOARD_CH, "TOUCH|" + (string)who); } } listen(integer ch, string name, key id, string msg) { if (msg == "BOARD_UP") { BOARD_KEY = NULL_KEY; hello(); return; } if (msg == "WELCOME") { BOARD_KEY = id; llSetTimerEvent(0.0); return; } if (id != BOARD_KEY) return; if (llGetSubString(msg, 0, 1) == "H|") { list p = llParseStringKeepNulls(msg, ["|"], []); H_BALL = llList2String(p, 1); H_NAME = llList2String(p, 2); H_ROLE = llList2String(p, 3); H_OPEN = llList2String(p, 4); H_CURRENT = (integer)llList2String(p, 5); ENTRIES = []; } else if (llGetSubString(msg, 0, 1) == "E|") { ENTRIES += llParseString2List(llGetSubString(msg, 2, -1), ["^"], []); } else if (msg == "END") { drawCard(); } } timer() { if (BOARD_KEY == NULL_KEY) hello(); else llSetTimerEvent(0.0); } }