// =============================================== // I>NSANE KAOs RECEIVER HUD (OpenSim/LSL) // Listens on channel xxxxxx and applies textures // =============================================== integer CHANNEL = xxxxxx; // ------------------------------------------ // Mapping: Button -> prim name and face (stride 3) // [ "Button", "PrimName", Face, ... ] // ------------------------------------------ list MAP = [ // Lips (prim: lips, face X) "Lip1", "lips", X, "Lip2", "lips", X, "Lip3", "lips", X, "Lip4", "lips", X, "Lip5", "lips", X, "Lip6", "lips", X, "Lip7", "lips", X, "Lip8", "lips", X, // Lashes (prim: face, face X) "Lash1", "face", X, "Lash2", "face", X, "Lash3", "face", X, "Lash4", "face", X, "Lash5", "face", X, "Lash6", "face", X, // Brows (prim: face, face X) "Brow1", "face", X, "Brow2", "face", X, "Brow3", "face", X, "Brow4", "face", X, "Brow5", "face", X, "Brow6", "face", X, "Brow7", "face", X, "Brow8", "face", X, // Shadows (prim: face, face X) "Shadow1", "face", X, "Shadow2", "face", X, "Shadow3", "face", X, "Shadow4", "face", X, "Shadow5", "face", X, "Shadow6", "face", X, "Shadow7", "face", X ]; // ------------------------------------------ // Find prim link number by name // ------------------------------------------ integer GetLinkByName(string name) { integer total = llGetNumberOfPrims(); integer i; for (i = 1; i <= total; i++) { if (llGetLinkName(i) == name) return i; } return -1; } // ------------------------------------------ // Transparency by prim/face // - Returns -1.0 if alpha should not be changed // ------------------------------------------ float GetAlpha(string prim, integer face) { if (prim == "lips" && face == 5) return 0.92; // 8% transparent if (prim == "face" && (face == 1 || face == 2)) return 0.92; // 8% transparent // face prim, face 5: do not change alpha return -1.0; } // ------------------------------------------ // Events // ------------------------------------------ default { state_entry() { llListen(CHANNEL, "", NULL_KEY, ""); } changed(integer change) { if (change & CHANGED_OWNER) { llResetScript(); } } listen(integer channel, string name, key id, string msg) { // Only accept messages from the same owner if (llGetOwner() != llGetOwnerKey(id)) return; // Expected format: "Button|UUID" list parts = llParseString2List(msg, ["|"], []); if (llGetListLength(parts) != 2) return; string button = llList2String(parts, 0); string uuid = llList2String(parts, 1); // Search in MAP (stride 3) integer stride = 3; integer len = llGetListLength(MAP); integer i; for (i = 0; i < len; i += stride) { if (llList2String(MAP, i) == button) { string prim = llList2String(MAP, i + 1); integer face = llList2Integer(MAP, i + 2); integer link = GetLinkByName(prim); if (link != -1) { // Apply texture llSetLinkPrimitiveParamsFast( link, [ PRIM_TEXTURE, face, uuid, <1.0,1.0,0.0>, <0.0,0.0,0.0>, 0.0 ] ); // Apply alpha if needed float a = GetAlpha(prim, face); if (a >= 0.0) { llSetLinkAlpha(link, a, face); } } // Stop after processing return; } } } }