From d7b8fe407523b6d5666cb361dfb726f0235e8189 Mon Sep 17 00:00:00 2001 From: Serie Sumei Date: Sun, 21 Jun 2020 20:13:39 -0500 Subject: [PATCH 1/4] ss HUD: OpenSimulator 0.8 compatibility for ro2_hud_control --- Scripts/ro2_hud_control.lsl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Scripts/ro2_hud_control.lsl b/Scripts/ro2_hud_control.lsl index 35a9da0..ad74ee4 100644 --- a/Scripts/ro2_hud_control.lsl +++ b/Scripts/ro2_hud_control.lsl @@ -6,10 +6,19 @@ // v2.0 12Apr2020 - Based on ru2_hud_control.lsl v3.2 // v2.1 12Apr2020 - New simpler alpha HUD // v2.2 13May2020 - Rework skin panel +// v2.3 21Jun2020 - Updates to compile on OpenSimulator 0.8 // This is a heavily modified version of Shin's RC3 HUD scripts for alpha // and skin selections. +// Older OpenSimulator builds may not have the PRIM_ALPHA_MODE_* +// constants defined. If you get a compiler error that these are not defined +// uncomment the following lines: +// integer PRIM_ALPHA_MODE_NONE = 0; +// integer PRIM_ALPHA_MODE_BLEND = 1; +// integer PRIM_ALPHA_MODE_MASK = 2; +// integer PRIM_ALPHA_MODE_EMISSIVE = 3; + // The app ID is used on calculating the actual channel number used for communication // and must match in both the HUD and receivers. integer APP_ID = 20181024; @@ -165,7 +174,7 @@ integer do_fp = FALSE; // Skin / Bakes on Mesh integer current_skin = -1; integer current_eye = -1; -integer alpha_mode = PRIM_ALPHA_MODE_MASK; +integer alpha_mode; integer mask_cutoff = 128; // Map skin selections to button faces @@ -482,6 +491,8 @@ init() { last_attach = llGetAttached(); log("state_entry() attached=" + (string)last_attach); + alpha_mode = PRIM_ALPHA_MODE_MASK; + r2channel = keyapp2chan(APP_ID); llListen(r2channel+1, "", "", ""); llMessageLinked(LINK_THIS, LINK_RUTH_APP, llList2CSV(["appid", APP_ID]), ""); From c1a742ad2d56ed63851351f3715dcdba66851190 Mon Sep 17 00:00:00 2001 From: Serie Sumei Date: Sun, 21 Jun 2020 19:58:49 -0500 Subject: [PATCH 2/4] ss HUD: Revise r2_applier to not use JSON functions It turns out the llGetJsonValue() function isn't supported in older OpenSimulator releases that are still in common use. We can use lists easily enough here so make the switch upstream. --- Scripts/r2_applier.lsl | 76 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/Scripts/r2_applier.lsl b/Scripts/r2_applier.lsl index 2ae40ca..c2730a3 100644 --- a/Scripts/r2_applier.lsl +++ b/Scripts/r2_applier.lsl @@ -3,6 +3,7 @@ // Copyright 2020 Serie Sumei // v2.0 - 09May2020 - New applier script +// v2.1 - 21Jun2020 - Rework skin data to not use JSON functions // This script loads a notecard with skin and eye texture UUIDs // and listens for link messages with button names to @@ -38,14 +39,18 @@ key notecard_qid; integer line; integer reading_notecard = FALSE; string current_section; -string current_buffer; +list current_buffer; // Skin textures +// skin_config stores 5 sub-elements: section, thumbnail, head, upper, lower +integer skin_stride = 5; list skin_config; list skin_map; list skin_thumbnails; -// Skin textures +// Eye textures +// eye_config stores 3 sub-elements: section, thumbnail, eyes +integer eye_stride = 3; list eye_config; list eye_map; list eye_thumbnails; @@ -89,13 +94,6 @@ integer keyapp2chan(integer id) { return 0x80000000 | ((integer)("0x" + (string)llGetOwner()) ^ id); } -send_region(string region) { - string skin_tex = llJsonGetValue(current_buffer, [region]); - if (skin_tex != "") { - send("TEXTURE," + region + "," + skin_tex); - } -} - // Send the list of skin_thumbnails back to the HUD for display send_skin_thumbnails() { llMessageLinked(LINK_THIS, LINK_RUTH_HUD, llList2CSV( @@ -118,24 +116,30 @@ send_eye_thumbnails() { ), ""); } +// This is the v1 TEXTURE API +send_texture(string region, string tex) { + if (region != "" && tex != "") { + send("TEXTURE," + region + "," + tex); + } +} + apply_skin_texture(string button) { log("r2_applier: button=" + button); if (button == "bom") { // Note: if you get a compiler error that these are undefined // uncomment the lines near the top of this script - send("TEXTURE,upper," + (string)IMG_USE_BAKED_UPPER); - send("TEXTURE,lower," + (string)IMG_USE_BAKED_LOWER); - send("TEXTURE,head," + (string)IMG_USE_BAKED_HEAD); + send_texture("head", IMG_USE_BAKED_HEAD); + send_texture("upper", IMG_USE_BAKED_UPPER); + send_texture("lower", IMG_USE_BAKED_LOWER); return; } integer i = llListFindList(skin_map, [button]); if (i >= 0) { - current_buffer = llList2String(skin_config, i); - send_region("head"); - send_region("upper"); - send_region("lower"); + send_texture("head", llList2String(skin_config, (i * skin_stride) + 2)); + send_texture("upper", llList2String(skin_config, (i * skin_stride) + 3)); + send_texture("lower", llList2String(skin_config, (i * skin_stride) + 4)); } } @@ -143,18 +147,16 @@ apply_eye_texture(string button) { log("r2_applier: button=" + button); if (button == "bom") { - send("TEXTURE,lefteye," + (string)IMG_USE_BAKED_EYES); - send("TEXTURE,righteye," + (string)IMG_USE_BAKED_EYES); + send_texture("lefteye", IMG_USE_BAKED_EYES); + send_texture("righteye", IMG_USE_BAKED_EYES); return; } integer i = llListFindList(eye_map, [button]); if (i >= 0) { - current_buffer = llList2String(eye_config, i); - string eye_tex = llJsonGetValue(current_buffer, ["eyes"]); - send("TEXTURE,lefteye," + (string)eye_tex); - send("TEXTURE,righteye," + (string)eye_tex); -// send_region("eyes"); + string eye_tex = llList2String(eye_config, (i * eye_stride) + 2); + send_texture("lefteye", eye_tex); + send_texture("righteye", eye_tex); } } @@ -192,7 +194,8 @@ load_notecard(string name) { log("r2_applier: Reading notecard: " + notecard_name); if (can_haz_notecard(notecard_name)) { line = 0; - current_buffer = ""; + // Need to pre-load current_buffer, must be at least the longest stride + current_buffer = ["", "", "", "", ""]; reading_notecard = TRUE; skin_config = []; skin_map = []; @@ -208,14 +211,16 @@ save_section() { // Save what we have log(" " + current_section + " " + (string)current_buffer); string value; - value = llJsonGetValue(current_buffer, ["thumbnail"]); + + // Get thumbnail + value = llList2String(current_buffer, 1); + if (llGetSubString(current_section, 0, 3) == "skin") { skin_config += current_buffer; skin_map += llGetSubString(current_section, 4, -1); - if (value != "" && value != JSON_INVALID) { + if (value != "") { // Move the thumbnail UUID to that list skin_thumbnails += value; - current_buffer = llJsonSetValue(current_buffer, ["thumbnail"], JSON_DELETE); } else { skin_thumbnails += ""; } @@ -223,17 +228,17 @@ save_section() { else if (llGetSubString(current_section, 0, 3) == "eyes") { eye_config += current_buffer; eye_map += llGetSubString(current_section, 4, -1); - if (value != "" && value != JSON_INVALID) { + if (value != "") { // Move the thumbnail UUID to that list eye_thumbnails += value; - current_buffer = llJsonSetValue(current_buffer, ["thumbnail"], JSON_DELETE); } else { eye_thumbnails += ""; } } // Clean up for next line - current_buffer = ""; + // Need to pre-load current_buffer, must be at least the longest stride + current_buffer = ["", "", "", "", ""]; current_section = ""; } @@ -254,6 +259,7 @@ read_config(string data) { if (end != 0) { // Well-formed section header current_section = llGetSubString(data, 1, end-1); + current_buffer = llListReplaceList(current_buffer, [current_section], 0, 0); log("Reading section " + current_section); } } else { @@ -267,23 +273,23 @@ read_config(string data) { if (attr == "head" || attr == "omegaHead") { // Save head - current_buffer = llJsonSetValue(current_buffer, ["head"], value); + current_buffer = llListReplaceList(current_buffer, [value], 2, 2); } else if (attr == "upper" || attr == "lolasSkin") { // Save upper body - current_buffer = llJsonSetValue(current_buffer, ["upper"], value); + current_buffer = llListReplaceList(current_buffer, [value], 3, 3); } else if (attr == "lower" || attr == "skin") { // Save upper body - current_buffer = llJsonSetValue(current_buffer, ["lower"], value); + current_buffer = llListReplaceList(current_buffer, [value], 4, 4); } else if (attr == "thumbnail") { // Save upper body - current_buffer = llJsonSetValue(current_buffer, ["thumbnail"], value); + current_buffer = llListReplaceList(current_buffer, [value], 1, 1); } else if (attr == "eyes") { // Save eyes - current_buffer = llJsonSetValue(current_buffer, ["eyes"], value); + current_buffer = llListReplaceList(current_buffer, [value], 2, 2); } else { // llOwnerSay("Unknown configuration value: " + name + " on line " + (string)line); From dee03507e686f5647c6b4bcd82e294ea2db184b8 Mon Sep 17 00:00:00 2001 From: Serie Sumei Date: Sun, 21 Jun 2020 16:47:53 -0500 Subject: [PATCH 3/4] ss HUD: Revise r2_applier for opensim 0.8 * Declare missing constant equivalents --- Scripts/r2_applier.lsl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Scripts/r2_applier.lsl b/Scripts/r2_applier.lsl index c2730a3..6c20512 100644 --- a/Scripts/r2_applier.lsl +++ b/Scripts/r2_applier.lsl @@ -4,6 +4,7 @@ // v2.0 - 09May2020 - New applier script // v2.1 - 21Jun2020 - Rework skin data to not use JSON functions +// v2.1-os08-1 - 21Jun2020 - Updates to compile on OpenSimulator 0.8 // This script loads a notecard with skin and eye texture UUIDs // and listens for link messages with button names to @@ -24,10 +25,10 @@ // Halcyon and older OpenSimulator builds may not have the Bakes on Mesh // constants defined. If you get a compiler error that these are not defined // uncomment the following lines: -// string IMG_USE_BAKED_UPPER = ""; -// string IMG_USE_BAKED_LOWER = "" ; -// string IMG_USE_BAKED_HEAD = ""; -// string IMG_USE_BAKED_EYES = ""; +string IMG_USE_BAKED_UPPER = ""; +string IMG_USE_BAKED_LOWER = "" ; +string IMG_USE_BAKED_HEAD = ""; +string IMG_USE_BAKED_EYES = ""; integer DEFAULT_APP_ID = 20181024; integer app_id; From c697c173b57a1673cbe2c3d61f3c570faf95af30 Mon Sep 17 00:00:00 2001 From: Serie Sumei Date: Sun, 21 Jun 2020 20:20:26 -0500 Subject: [PATCH 4/4] ss HUD: Revise ro2_hud_control for OpenSimulator 0.8 --- Scripts/ro2_hud_control.lsl | 61 ++++++------------------------------- 1 file changed, 9 insertions(+), 52 deletions(-) diff --git a/Scripts/ro2_hud_control.lsl b/Scripts/ro2_hud_control.lsl index ad74ee4..c916428 100644 --- a/Scripts/ro2_hud_control.lsl +++ b/Scripts/ro2_hud_control.lsl @@ -7,6 +7,7 @@ // v2.1 12Apr2020 - New simpler alpha HUD // v2.2 13May2020 - Rework skin panel // v2.3 21Jun2020 - Updates to compile on OpenSimulator 0.8 +// v2.3-os08-1 21Jun2020 - Uncomment constants for OpenSimulator 0.8 // This is a heavily modified version of Shin's RC3 HUD scripts for alpha // and skin selections. @@ -14,10 +15,10 @@ // Older OpenSimulator builds may not have the PRIM_ALPHA_MODE_* // constants defined. If you get a compiler error that these are not defined // uncomment the following lines: -// integer PRIM_ALPHA_MODE_NONE = 0; -// integer PRIM_ALPHA_MODE_BLEND = 1; -// integer PRIM_ALPHA_MODE_MASK = 2; -// integer PRIM_ALPHA_MODE_EMISSIVE = 3; +integer PRIM_ALPHA_MODE_NONE = 0; +integer PRIM_ALPHA_MODE_BLEND = 1; +integer PRIM_ALPHA_MODE_MASK = 2; +integer PRIM_ALPHA_MODE_EMISSIVE = 3; // The app ID is used on calculating the actual channel number used for communication // and must match in both the HUD and receivers. @@ -305,55 +306,11 @@ adjust_pos() { } -// ***** -// get/set alpha values in JSON buffer - -// j - JSON value storage -// name - link_name -// face - integer face, -1 returns the unmasked 16 bit value -// Internal JSON values are ones complement, ie a 1 bit means the face is not visible -integer json_get_alpha(string j, string name, integer face) { - integer cur_val = (integer)llJsonGetValue(j, [name]); - if (face < 0) { - // All faces, return aggregate value masked to 16 bits - cur_val = ~cur_val & 0xffff; - } else { - cur_val = (cur_val & (1 << face)) == 0; - } - return cur_val; -} - -// j - JSON value storage -// name - link_name -// face - integer face, -1 sets all 16 bits in the value -// value - alpha boolean, 0 = invisible, 1 = visible -// Internal JSON values are ones complement, ie a 1 bit means the face is not visible -string json_set_alpha(string j, string name, integer face, integer value) { - value = !value; // logical NOT for internal storage - integer cur_val = (integer)llJsonGetValue(j, [name]); - integer mask; - integer cmd; - if (face < 0) { - // All faces - mask = 0x0000; - // One's complement - cmd = -value; - } else { - mask = ~(1 << face); - cmd = (value << face); - } - // Mask final value to 16 bits - cur_val = ((cur_val & mask) | cmd) & 0xffff; - return llJsonSetValue(j, [name], (string)(cur_val)); -} -// ***** - - // Set the alpha val of all links matching name set_alpha(string name, integer face, float alpha) { log("set_alpha(): name="+name+" face="+(string)face+" alpha="+(string)alpha); send_csv(["ALPHA", name, face, alpha]); - current_alpha = json_set_alpha(current_alpha, name, face, (integer)alpha); +// current_alpha = json_set_alpha(current_alpha, name, face, (integer)alpha); integer link; for (; link < num_links; ++link) { // Set color for all matching link names @@ -377,11 +334,11 @@ set_alpha_section(string section_name, integer alpha) { if (alpha < 0) { // Toggle the current value log("json: " + current_alpha); - alpha = !json_get_alpha(current_alpha, section_name, 0); +// alpha = !json_get_alpha(current_alpha, section_name, 0); log("val: " + (string)alpha); } send_csv(["ALPHA", section_name, 0, alpha]); - current_alpha = json_set_alpha(current_alpha, section_name, 0, (integer)alpha); +// current_alpha = json_set_alpha(current_alpha, section_name, 0, (integer)alpha); } } } @@ -393,7 +350,7 @@ reset_alpha(float alpha) { for (section = 0; section < len; ++section) { string section_name = llList2String(alpha_buttons, section); send_csv(["ALPHA", section_name, 0, alpha]); - current_alpha = json_set_alpha(current_alpha, section_name, 0, (integer)alpha); +// current_alpha = json_set_alpha(current_alpha, section_name, 0, (integer)alpha); } // Reset HUD buttons