Galaxy Littlepaws Posted December 11, 2018 Share Posted December 11, 2018 I'm wanting to find a way for a script to check the color of a linked prim and put it in a string for use in other parts of the script. Something like this: string color=[prim_color 3] How can I do this, or is it something that would have to be done in another way? Link to comment Share on other sites More sharing options...
KT Kingsley Posted December 11, 2018 Share Posted December 11, 2018 The function llGetLinkPrimitiveParams will get the colour of a linked prim: http://wiki.secondlife.com/wiki/LlGetLinkPrimitiveParams#llGetLinkPrimitiveParams. Because colours in scripts are stored as vectors, and you say you want to use it in other parts of your script, you may be better off storing the colour that way rather than having to remember to convert a string back to a vector each time you use it in a function. Now, llGetLinkPrimitiveParams returns a list, and, in the case of PRIM_COLOR, it's a list of two items: the first is the colour vector, and the second is the alpha (transparency) as a float. You must extract the colour vector from the list and can ignore the alpha float. list prim_color = llGetLinkPrimitiveParams (link_number, [PRIM_COLOR, face_number]); vector color = llList2Vector (prim_color, 0); Or, if you really do need it as a string: string color = (string) llList2Vector (prim_color, 0); 1 Link to comment Share on other sites More sharing options...
Galaxy Littlepaws Posted December 11, 2018 Author Share Posted December 11, 2018 For some reason, it's giving me a syntax error on the first ( character on any of those lines. I'm not entirely sure what I'm doing wrong here. I'm putting it with the other string, integer, float, and vector lines at the beginning of the script. Link to comment Share on other sites More sharing options...
Galaxy Littlepaws Posted December 11, 2018 Author Share Posted December 11, 2018 As I've made only small edits to this script I'm willing to paste the entire thing in here for context. I want it to check the color of a linked prim and then during the "closed" or "dead" states change the "eye" prim this script works with to have that color and change back to white when open. // :CATEGORY:XS Pet // :NAME:Breedable_pet_eye_scripts // :AUTHOR:Ferd Frederix // :CREATED:2012-08-16 10:21:14.630 // :EDITED:2013-09-17 21:48:30 // :ID:116 // :NUM:175 // :REV:1.0 // :WORLD:Second Life // :DESCRIPTION: // Combined eye and particle script. // // This script flips between two textures for eye blinking and also supports a 'dead' eye look. It combines the particle plug-in with eyes together. It may be more useful on non-robot pets. // An article on how to use it, including a set of example eye textures, is located at <a href="http://www.outworldz.com/secondlife/posts/breedable-pet-robot/blinking%20eyes.htm">http://www.outworldz.com/secondlife/posts/breedable-pet-robot/blinking%20eyes.htm</a> // :CODE: // This code is licensed as Creative Commons Attribution/NonCommercial/Share Alike // See http://creativecommons.org/licenses/by-nc-sa/3.0/ // Noncommercial -- You may not use this work for commercial purposes // If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one. // This means that you cannot sell this code but you may share this code. // You must attribute authorship to me and leave this notice intact. // // Exception: I am allowing this script to be sold inside an original build. // You are not selling the script, you are selling the build. // Ferd Frederix // the names of the textures for eyes that shut and close by flipping between them. string OPEN = "eyes open"; string CLOSED = "eyes closed"; string DEAD = "eyes dead"; // could be a copy of eyes closed, or (X)(X) string ANI_DIE = "death"; // a string taught to the pet by the animator when the animal is to die. string ANI_SLEEP = "sleep"; // Sleeping string ANI_STAND = "stand"; // default standing animation integer numberPrim_eyeL = 3; integer numberPrim_eyeR = 4; vector repeatsTexture = <1.2,1.2,0>; float rotationTexture =223.0; vector offsetTexture = ZERO_VECTOR; integer numberSide = ALL_SIDES; float randomTimer = 3.0; float staticTimer = 3.0; float randomSleep = 0.2; float staticSleep = 0.1; integer flags; // Original Particle Script 0.4j // Created by Ama Omega 3-7-2004 // Updated by Jopsy Pendragon 5-11-2004 // For classes/tutorials/tricks, visit the Particle Labratory in Teal // Values marked with (*) are defaults. default { on_rez(integer startparam) { llResetScript(); } state_entry() { llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, CLOSED, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, CLOSED , repeatsTexture, offsetTexture, rotationTexture ]); llSetTimerEvent(llFrand(randomTimer) + staticTimer); } timer() { llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, CLOSED, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, CLOSED , repeatsTexture, offsetTexture, rotationTexture ]); llSleep( llFrand(randomSleep) + staticSleep ); llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, OPEN, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, OPEN, repeatsTexture, offsetTexture, rotationTexture ]); } link_message(integer sender, integer num, string str, key id) { if (num == 1 && str == ANI_SLEEP ) { llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, CLOSED, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, CLOSED , repeatsTexture, offsetTexture, rotationTexture ]); //closed llSetTimerEvent(0); // no blink } else if (num == 1 && str == ANI_STAND) { llParticleSystem( [] ); // turn off particle ZZZ's by sending an empty list llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, OPEN, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, OPEN, repeatsTexture, offsetTexture, rotationTexture ]); //open llSetTimerEvent(llFrand(3) + 3); } else if (num == 1 && str == ANI_DIE) { llSetLinkPrimitiveParamsFast( numberPrim_eyeL, [ PRIM_TEXTURE, numberSide, CLOSED, repeatsTexture, offsetTexture, rotationTexture, PRIM_LINK_TARGET, numberPrim_eyeR , PRIM_TEXTURE, numberSide, CLOSED , repeatsTexture, offsetTexture, rotationTexture ]); // dead eye (X)(X) texture llParticleSystem( [ ] ); // turn off particle ZZZ's llSetTimerEvent(0); // no blink } } } Link to comment Share on other sites More sharing options...
KT Kingsley Posted December 11, 2018 Share Posted December 11, 2018 Those lines of code need to go inside an event. The declarations at the start of the script can only contain constants, and not calculations. Looking at the script you've posted, I'm wondering if when you say color, you're actually talking about the texture. And I'm wondering if what you want to do is to stop the animal from going dead-eyed, or blinking, or sleeping. Or do you want to keep that and counteract an actual prim color change that some other script is causing? Link to comment Share on other sites More sharing options...
Galaxy Littlepaws Posted December 11, 2018 Author Share Posted December 11, 2018 I mean color. Right now it handles textures, but I want to add the color changes in combination. As of right now, the eyes are white, but in the "closed" and "dead" state the white looks odd when compared to the rest of the body. I can't just use a colored texture because of how the color of the body prim changes. And making the eye constantly the color of the body would make the "eye open" texture look horrible. No other script is touching the eye prim color. 6 minutes ago, KT Kingsley said: Those lines of code need to go inside an event. The declarations at the start of the script can only contain constants, and not calculations. Looking at the script you've posted, I'm wondering if when you say color, you're actually talking about the texture. And I'm wondering if what you want to do is to stop the animal from going dead-eyed, or blinking, or sleeping. Or do you want to keep that and counteract an actual prim color change that some other script is causing? Link to comment Share on other sites More sharing options...
KT Kingsley Posted December 11, 2018 Share Posted December 11, 2018 (edited) I get you. So, where the eye texture is changed to one where you want to change the prim colour you can get the original prim colour and save it as a global variable. And when the texture is changed back to one where you want to restore the original prim colour you can use that saved colour. Add something like vector original_eye_prim_color; vector modified_eye_prim_color = <0.5, 0.5, 0.5>; //the prim color to use when the eye is closed (mid-grey here, but choose what works best) to those oher declarations at the start of the script. Immediately after those llSetLinkPrimitiveParamsFast calls that change the eye texture to closed get the original prim colour, and then set the modified prim colour: original_eye_prim_color = llList2Vector (llGetLinkPrimitiveParams (numberPrim_eyeL, [PRIM_COLOR, ALL_SIDES]), 0); llSetLinkColor (numberPrim_eyeL, modified_eye_prim_color, ALL_SIDES); llSetLinkColor (numberPrim_eyeR, modified_eye_prim_color, ALL_SIDES); Then when the texture gets changed back to open, reset the prim colour back to the original: llSetLinkColor (numberPrim_eyeL, original_eye_prim_color, ALL_SIDES); llSetLinkColor (numberPrim_eyeR, original_eye_prim_color, ALL_SIDES); I suspect you only really need to save the original prim colour just once, in the state_entry event. Is this helping? Edited December 11, 2018 by KT Kingsley Color v. colour 1 Link to comment Share on other sites More sharing options...
Galaxy Littlepaws Posted December 11, 2018 Author Share Posted December 11, 2018 31 minutes ago, KT Kingsley said: I get you. So, where the eye texture is changed to one where you want to change the prim colour you can get the original prim colour and save it as a global variable. And when the texture is changed back to one where you want to restore the original prim colour you can use that saved colour. Add something like vector original_eye_prim_color; vector modified_eye_prim_color = <0.5, 0.5, 0.5>; //the prim color to use when the eye is closed (mid-grey here, but choose what works best) to those oher declarations at the start of the script. Immediately after those llSetLinkPrimitiveParamsFast calls that change the eye texture to closed get the original prim colour, and then set the modified prim colour: original_eye_prim_color = llList2Vector (llGetLinkPrimitiveParams (numberPrim_eyeL, [PRIM_COLOR, ALL_SIDES]), 0); llSetLinkColor (numberPrim_eyeL, modified_eye_prim_color, ALL_SIDES); llSetLinkColor (numberPrim_eyeR, modified_eye_prim_color, ALL_SIDES); Then when the texture gets changed back to open, reset the prim colour back to the original: llSetLinkColor (numberPrim_eyeL, original_eye_prim_color, ALL_SIDES); llSetLinkColor (numberPrim_eyeR, original_eye_prim_color, ALL_SIDES); I suspect you only really need to save the original prim colour just once, in the state_entry event. Is this helping? Yes, I've added those in and they look like they'll work. How do I change the modified_eye_prim_color to always be whatever the body prim is instead of a set value? The body is the 3rd prim in this linked object. Or should I have the script that controls the body color somehow talk to the eye script to set that value? Link to comment Share on other sites More sharing options...
Galaxy Littlepaws Posted December 11, 2018 Author Share Posted December 11, 2018 Okay, I figured out how to get the body script to tell the eye script what color to use for the modified_eye_prim_color variable by cross-referencing other scripts I've been using. Thanks for the help! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now