LlGetLinkPrimitiveParams
De DigiWiki.
Version du 11 août 2012 à 14:55 par Djphil (discuter | contributions)
string msg = "Object is "; integer isLight; vector colour; float intensity; float radius; float falloff; list params = llGetLinkPrimitiveParams(LINK_THIS, [PRIM_POINT_LIGHT]); isLight = llList2Integer(params, 0); if (isLight == FALSE) msg += "not a light source."; else { colour = llList2Vector(params, 1); intensity = llList2Float(params, 2); radius = llList2Float(params, 3); falloff = llList2Float(params, 4); msg += "a point light source.\nColour = "+(string)colour; msg += "\nIntensity = "+(string)intensity; msg += "\nRadius = "+(string)radius; msg += "\nFalloff = "+(string)falloff; } llSay(0, msg);
//code snippets by Strife Onizuka, Xen Lisle and Kireji Haiku integer AreAllPrimsAreGlowing() { //The root prim is either link number is 0 or 1 //It is only zero if it is a single prim object with no avatars sitting on it. //llGetNumberOfPrims() returns the number of prims and seated avatars. integer link = llGetNumberOfPrims() > 1; //We want to loop over all prims but not avatars, so we need to know how many prims there are. //Fortunately the avatars are added to the end of the link set, their link numbers always come after the last prim. //llGetObjectPrimCount(llGetKey()) only returns only the number of prims, it doesn't count avatars. //To determine the upper bound, we need to take into consideration the link number of the root prim. integer end = link + llGetObjectPrimCount(llGetKey()); for(;link < end; ++link)//loop through all prims { if( llListStatistics(LIST_STAT_MAX, llGetLinkPrimitiveParams(link, [PRIM_GLOW, ALL_SIDES])) <= 0.0) {//we can exit early because we know that if this value is less than or equal to zero, so will the minimum return FALSE; } } //we didn't find a single value that was less than or equal to zero, QED, they are all greater than zero. return TRUE; } default { touch_start(integer num_detected) { if(AreAllPrimsAreGlowing()) llSay(0, "All prims glowing."); else llSay(0, "Not all prims glowing."); } }
list GetLinkPrimitiveParams(integer link, list input) {//Returns a list that can be fed to llSetPrimitiveParams list output; integer c = ~llGetListLength(input); while(0x80000000 & (c = - ~c)) { list flag = (list)llList2Integer(input, c); if(~llListFindList([PRIM_BUMP_SHINY, PRIM_COLOR, PRIM_TEXTURE, PRIM_FULLBRIGHT, PRIM_TEXGEN, PRIM_GLOW], flag )) { integer side = llList2Integer(input, (c = - ~c)); if(~side)//pop the stack output += flag + side + llGetLinkPrimitiveParams(link, flag + side ); else for(side = llGetLinkNumberOfSides(link); side; ) //we return the sides in reverse order, easier to code; runs faster. output += flag + side + llGetLinkPrimitiveParams(link, flag + (side = ~ -side) ); } else output += flag + llGetLinkPrimitiveParams(link, flag ); } return output; } //Contributed by Strife Onizuka