Reo Ninetails Posted March 12, 2014 Share Posted March 12, 2014 Hello, I am very very new to scripting.I am trying to make a script that when not flying, the object I am wearing is invisible, and when I fly it will make the object visible and turn on the light from it. Can anyone get me started in the right direction? Thanks in advanced! Link to comment Share on other sites More sharing options...
Xiija Posted March 12, 2014 Share Posted March 12, 2014 check here ... http://wiki.secondlife.com/wiki/LlGetAgentInfo in your script you would do something in a timer event like... timer() { status = llGetAgentInfo( llGetOwner() ); if( status & AGENT_FLYING) { // do stuff to change the alpha & turn on the light } else if( status & !AGENT_FLYING) { // do stuff to turn off lyte & make invis } } the invis stuff can use ... http://wiki.secondlife.com/wiki/LlSetLinkAlpha and the light can use... http://wiki.secondlife.com/wiki/LlSetLinkPrimitiveParamsFast#llSetLinkPrimitiveParamsFast yell if ya get stuck Link to comment Share on other sites More sharing options...
Reo Ninetails Posted March 12, 2014 Author Share Posted March 12, 2014 Thanks a bunch! I'll see what I can come up with :3 Link to comment Share on other sites More sharing options...
Reo Ninetails Posted March 12, 2014 Author Share Posted March 12, 2014 So this is what I came up with so far. Correct me if I am wrong. I am still really new to this. I have not even begun to even try to turn the lights off/on lol. default { state_entry() { _owner = llGetOwner(); llSetTimerEvent(); } timer() { status = llGetAgentInfo( llGetOwner() ); if( status & AGENT_FLYING) { // do stuff to change the alpha & turn on the light llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); llSetTimerEvent(0.0); } } { else if( status & !AGENT_FLYING) { // do stuff to turn off lyte & make invis // opaque llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES); llSetTimerEvent(0.0); } } Link to comment Share on other sites More sharing options...
Xiija Posted March 12, 2014 Share Posted March 12, 2014 you are close try this... you may need to mess with the SLPPF settings for the light.. you need to leave the timer on all the time... the light settings are <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0 <1.0, 1.0, 1.0> is the color WHITE, 1.0, 20.0, 1.0 is ... intensity, radius, and falloff integer status;default{ state_entry() { llSetTimerEvent(1); // timer fires every second } timer() { status = llGetAgentInfo( llGetOwner() ); if( status & AGENT_FLYING) // if you are flying { llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES); // set alpha to 1.0 ( visible) llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,TRUE, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); // TRUE = light ON } else // if you are NOT flying { llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES); // set alpha to invis 0.0 llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,FALSE, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); // FALSE = light OFF } }} Link to comment Share on other sites More sharing options...
revochen Mayne Posted March 12, 2014 Share Posted March 12, 2014 Although the script is working as expected, it has one downside. It will continue to set the light and alpha even if they are already set. To avoid this, there are just a few additional lines of code needed. Following script will check if the 'status' parameter is different to its previous state and only changes the prim light and alpha if so. integer previousStatus=-1;default{ state_entry() { llSetTimerEvent(1); // timer fires every second } timer() { integer status = llGetAgentInfo( llGetOwner() ); if( (status & AGENT_FLYING) && previousStatus!=AGENT_FLYING) // if you are flying (and not flying already) { // llOwnerSay("flying"); previousStatus = AGENT_FLYING; llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES); // set alpha to 1.0 ( visible) llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,TRUE, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); // TRUE = light ON } else if((status & AGENT_FLYING)==FALSE && previousStatus == AGENT_FLYING) // if you are NOT flying (and had AGENT_FLYING as previous status) { // llOwnerSay("not flying"); previousStatus = 0; llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES); // set alpha to invis 0.0 llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,FALSE, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); // FALSE = light OFF } }} Link to comment Share on other sites More sharing options...
revochen Mayne Posted March 12, 2014 Share Posted March 12, 2014 BTW I just figured there is also a short version for this code: integer previousStatus=-1;default{ state_entry() { llSetTimerEvent(1); // timer fires every second } timer() { integer agentInfo = llGetAgentInfo( llGetOwner() ); integer isFlying = (agentInfo&AGENT_FLYING); if(isFlying!=previousStatus) { //llOwnerSay(llList2String(["not flying","flying"],isFlying)); previousStatus = isFlying; llSetLinkAlpha(LINK_THIS, isFlying, ALL_SIDES); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,isFlying, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); } }} 1 Link to comment Share on other sites More sharing options...
Reo Ninetails Posted March 13, 2014 Author Share Posted March 13, 2014 Wow guys thanks for all of the awesome help! You all got me pushed in the right direction. I was even able to figure out how to turn the object glow on as well, thanks to all of the feedback I got. My first scripting project is almost complete. Wooo! Thanks again everyone! Link to comment Share on other sites More sharing options...
MaxNobaru Posted February 12 Share Posted February 12 On 3/12/2014 at 5:42 PM, revochen Mayne said: BTW I just figured there is also a short version for this code: integer previousStatus=-1;default{ state_entry() { llSetTimerEvent(1); // timer fires every second } timer() { integer agentInfo = llGetAgentInfo( llGetOwner() ); integer isFlying = (agentInfo&AGENT_FLYING); if(isFlying!=previousStatus) { //llOwnerSay(llList2String(["not flying","flying"],isFlying)); previousStatus = isFlying; llSetLinkAlpha(LINK_THIS, isFlying, ALL_SIDES); llSetLinkPrimitiveParamsFast(LINK_THIS, [ PRIM_POINT_LIGHT ,isFlying, <1.0, 1.0, 1.0>, 1.0, 20.0, 1.0]); } }} Hey gys, i was looking for a similar one, but when on AIR it glows, and when on gorund it hides i made up something to hide, but couldnt figure out how to glow at all, could you guys help? its like this key owner; default { on_rez(integer start_param) { llResetScript(); } changed(integer change) { if (change & (CHANGED_OWNER | CHANGED_INVENTORY)) llResetScript(); } state_entry() { owner = llGetOwner(); llSetTimerEvent(1.0); } timer() { integer ownerInfo = llGetAgentInfo(owner); if(ownerInfo & AGENT_IN_AIR) llSetAlpha((float)TRUE, ALL_SIDES); else llSetAlpha((float)FALSE, ALL_SIDES); } } Link to comment Share on other sites More sharing options...
Bugs Larnia Posted February 21 Share Posted February 21 Glow is set using llSetPrimitiveParams or llSetLinkPrimitiveParamsFast. If you pour it into a user defined function, you can simplify the call. I left out the alpha, but you can either add it or, more efficiently, implement it into the list of llSetPrimitiveParams rules. key gkOwner; integer giIsFlying; SetGlow(float pfGlowIntensity) { llSetPrimitiveParams([PRIM_GLOW, ALL_SIDES, pfGlowIntensity); } default { state_entry() { gkOwner = llGetOwner(); llSetTimerEvent(1.0); } changed(integer change) { if (change & (CHANGED_OWNER | CHANGED_INVENTORY)) llResetScript(); } timer() { integer ownerInfo = llGetAgentInfo(owner); if(ownerInfo & AGENT_IN_AIR) { if (!giIsFlying) { SetGlow(1.0); giIsFlying = TRUE; } } else { if (giIsFlying) { SetGlow(0.0); giIsFlying = FALSE; } } } on_rez(integer start_param) { llResetScript(); } } 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