Jump to content

What is wrong with this script?


FlintMorgan
 Share

You are about to reply to a thread that has been inactive for 3799 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

 
 link_message(integer linknum, integer num, string str, key id) {
     
        if(str == "died" || str == "detach" || str == "nohealth") {
            llMessageLinked(LINK_SET,1,"ok",NULL_KEY);
      
       //add here whatever disables the object
       
        }
        else if (str == "reset" || str == "attach") {
           
           //add here whatever enables the object again
        }
      
    }

Link to comment
Share on other sites


FlintMorgan wrote:

 

 
link_message(integer linknum, integer num, string str, key id) {             if(str == "died" || str == "detach" || str == "nohealth") {            llMessageLinked(LINK_SET,1,"ok",NULL_KEY);             //add here whatever disables the object               }        else if (str == "reset" || str == "attach") {                      //add here whatever enables the object again        }          }

 

Well, for starters, that's not a complete script by any means. It has no default state and it's missing code to actually do anything upon receipt of a message, as hinted at by the "add here whatever" comments.

What are you trying to do, Flint?

Link to comment
Share on other sites

First of all, welcome to the Forums!

 

There is only one of two ways a script can be "wrong":

  1. It doesn't compile, or
  2. It doesn't do what it's supposed to.

Since your code snippet would compile OK within a complete script, it apparently isn't doing what you expect of it. Looking at what you have, there are only comments describing expected behavior but no actual code to do anything along those lines.

 

To further your project, you first need to define for yourself exactly what "disabled" and "enabled" is about. And that can be further divided into changes in appearance (Does this entail a change in color, texture or hover text? Does the position or orientation change between these two states?) and changes in functionality (Does this affect how it reacts (or not) to input? Are certain actions only available when it's "enabled"?).

 

Once you have defined those differences, you'll next have to write the code to make the changes. That's just a matter of figuring out which of the many Linden Library Functions (https://wiki.secondlife.com/wiki/Category:LSL_Functions) accomplishes what you want done. You'll most likely also require a global variable (say, integer enabled = TRUE;) that will be used to keep track of whether or not the object is enabled at any given time

 

Starting with plain English comments and then defining them more precisely can help with this. At some point your comments will actually become the code!.

Link to comment
Share on other sites


Madelaine McMasters wrote:

You're shaming me with both your kindness and your generosity, LepreKhaun.

And pardon me for not noticing that was your debut post, Flint. Welcome aboard!

;-)

lol apparently no one here was shamed enough to reply to my last post so I deleted it.  May be I need to make a new alt every time I want to ask a question here.  Nothing personal Madelaine this comment is more directed to how the LSL forum seems to run.  Being nether new to sl, or a rl programmer, it seems hard for me to ask questions in a way that gets an answer on this forum. 

Link to comment
Share on other sites


phaedra Exonar wrote:

lol apparently no one here was shamed enough to reply to my last post so I deleted it.  May be I need to make a new alt every time I want to ask a question here.  Nothing personal Madelaine this comment is more directed to how the LSL forum seems to run.  Being nether new to sl, or a rl programmer, it seems hard for me to ask questions in a way that gets an answer on this forum. 

 If you wrote the OP, phaedra, the problem is that the question doesn't make sense.   What you posted isn't a script.  It's a fragment of a script which would, I think, work perfectly well if it were actually part of a script.   So, to take your question literally, what's wrong with it is that it's not a script.

It's like someone removing the engine from their car, and then taking the engine (disconnected from the fuel, electrics and everything else) into the garage and asking why it won't start.

 

Link to comment
Share on other sites

I posted a question about this yesterday with a longer explanation and got no reply, I saw your post here

http://community.secondlife.com/t5/LSL-Scripting/return-command/td-p/2360749

and thought I'd repost with a simpler question sense yours seam to get a lot of replies.

 

I working with a silhouette dance ball effect and need to force viewers to resort alpha textures when the object first rezzes.  The silhouette doesn't look right until some one changes their camera view ether by moving or zooming in and out this only happens when the object is first rezzed.  So I managed to force it with the script I posted in the post you linked to.  But I'd like to know more about why this works to be able to improve my script.  My guess is it has something to do with how the viewer decides when it needs to recalculate alpha texture sorting. If correct then I need to find the best way to force that recalculation.  If correct about needing to force the viewer to recalculate then what's the best way to force it.  Thought it might be one of those geeky question programmers would want to talk about kind of like this post

http://community.secondlife.com/t5/LSL-Scripting/Integers-and-floats/td-p/2350785

if you not sure what a silhouette dance ball is here's a link to an example all thou I'm using a different method to build it by twisting the sphere 180 degrees.

https://www.youtube.com/watch?v=CBs0PCKvb28

 

Link to comment
Share on other sites

I don't know if it's any consolation -- or maybe further aggravation -- but I spent about an hour fiddling with a silhouette ball when I saw your post. To be honest, it took me maybe ten minutes just to remember how they work (I don't think I've seen one in the wild for four years) and then none of the usual tricks to force an object update seemed to help with your problem. Then, after an unrelated crash, I happened to login with one of the things already in view and it rezzed to the viewer incorrectly right from the start, so that convinced me that it was going to be pretty ugly to script around a second-order glitch in what's kind of a viewer glitch anyway.

There are people who like to hack around on this sort of stuff, but at heart it's not really a scripting problem.

Link to comment
Share on other sites

I've just looked at an old ball of mine, made to this recipe.   In both the Official Viewer and Firestorm, any sorting problems resolved themselves after a moment without any intervention on my part.

 

 

 

default{	state_entry()	{		if (llGetNumberOfPrims()==2){			llSetLinkPrimitiveParamsFast(LINK_SET,[				PRIM_LINK_TARGET, 2,PRIM_TYPE,PRIM_TYPE_SPHERE,PRIM_HOLE_DEFAULT,<0.000000, 1.000000, 0.000000>,0.950000,<0.000000, 0.000000, 0.000000>,<0.000000, 1.000000, 0.000000>,				PRIM_PHANTOM,TRUE,				PRIM_SIZE, <2.76165, 2.76165, 2.76165>,				PRIM_ROT_LOCAL,<0.00000, 0.00000, 0.00000, 1.00000>,				PRIM_POS_LOCAL,<-0.02674, 0.00000, 0.00000>,				PRIM_SLICE,<0.00000, 1.00000, 0.00000>,				PRIM_COLOR,ALL_SIDES,<1.000000, 0.000000, 1.000000>,0.980392,				PRIM_TEXTURE,ALL_SIDES,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_LINK_TARGET, 1,PRIM_TYPE,PRIM_TYPE_SPHERE,PRIM_HOLE_DEFAULT,<0.000000, 1.000000, 0.000000>,0.950000,<0.000000, 0.000000, 0.000000>,<0.000000, 1.000000, 0.000000>,				PRIM_PHANTOM,TRUE,				PRIM_SIZE, <3.00000, 3.00000, 3.00000>,				PRIM_ROT_LOCAL,<0.00000, 0.70711, 0.00000, 0.70711>,				PRIM_SLICE,<0.00000, 1.00000, 0.00000>,				PRIM_COLOR,ALL_SIDES,<1.000000, 1.000000, 1.000000>,0.980392,				PRIM_TEXTURE,ALL_SIDES,"f2b7a72e-603f-c55b-33bb-6f729b5a7b0d",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,3,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796					]);			llRemoveInventory(llGetScriptName());		}		else{			llOwnerSay("This script works only with two, and exactly two, prims linked together");		}	}}

 

Link to comment
Share on other sites


Qie Niangao wrote:

I don't know if it's any consolation -- or maybe further aggravation -- but I spent about an hour fiddling with a silhouette ball when I saw your post. To be honest, it took me maybe ten minutes just to remember how they work (I don't think I've seen one in the wild for four years) and then none of the usual tricks to force an object update seemed to help with your problem. Then, after an unrelated crash, I happened to login with one of the things already in view and it rezzed to the viewer incorrectly right from the start, so that convinced me that it was going to be pretty ugly to script around a second-order glitch in what's kind of a viewer glitch anyway.

There are people who like to hack around on this sort of stuff, but at heart it's not really a scripting problem.

From my understanding of it, this is realted to alph sorting which appears glichy but from what  Chosen Few  says in this post here, so I'm not sure I'm ready to call it a glich in the same way invisiprims were/are

http://community.secondlife.com/t5/Mesh/Possible-work-around-for-alpha-sorting-problem/td-p/1227445

 

All so LepereKhaunhas provided some links and insight as to what my script is doing involving avatar's interest list.  You can find his comment here

http://community.secondlife.com/t5/LSL-Scripting/Force-viewer-to-sort-alpha-textures/td-p/2362347

 

I'm not one of those people looking around for hacks, I tend to fall in to the trap of finding some thing that intrest me and finding a use for it then finding it's a hack or has other issues.   Which is why i'm looking in to this now before I but some thing on the market.

Link to comment
Share on other sites


Innula Zenovka wrote:

I've just looked at an old ball of mine, made to this recipe.   In both the Official Viewer and Firestorm, any sorting problems resolved themselves after a moment without any intervention on my part.

 
 

 
default{	state_entry()	{		if (llGetNumberOfPrims()==2){			llSetLinkPrimitiveParamsFast(LINK_SET,[				PRIM_LINK_TARGET, 2,PRIM_TYPE,PRIM_TYPE_SPHERE,PRIM_HOLE_DEFAULT,<0.000000, 1.000000, 0.000000>,0.950000,<0.000000, 0.000000, 0.000000>,<0.000000, 1.000000, 0.000000>,				PRIM_PHANTOM,TRUE,				PRIM_SIZE, <2.76165, 2.76165, 2.76165>,				PRIM_ROT_LOCAL,<0.00000, 0.00000, 0.00000, 1.00000>,				PRIM_POS_LOCAL,<-0.02674, 0.00000, 0.00000>,				PRIM_SLICE,<0.00000, 1.00000, 0.00000>,				PRIM_COLOR,ALL_SIDES,<1.000000, 0.000000, 1.000000>,0.980392,				PRIM_TEXTURE,ALL_SIDES,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_LINK_TARGET, 1,PRIM_TYPE,PRIM_TYPE_SPHERE,PRIM_HOLE_DEFAULT,<0.000000, 1.000000, 0.000000>,0.950000,<0.000000, 0.000000, 0.000000>,<0.000000, 1.000000, 0.000000>,				PRIM_PHANTOM,TRUE,				PRIM_SIZE, <3.00000, 3.00000, 3.00000>,				PRIM_ROT_LOCAL,<0.00000, 0.70711, 0.00000, 0.70711>,				PRIM_SLICE,<0.00000, 1.00000, 0.00000>,				PRIM_COLOR,ALL_SIDES,<1.000000, 1.000000, 1.000000>,0.980392,				PRIM_TEXTURE,ALL_SIDES,"f2b7a72e-603f-c55b-33bb-6f729b5a7b0d",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,1,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,2,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796,				PRIM_TEXTURE,3,"5748decc-f629-461c-9a36-a35a221fe21f",<1.000000, 1.000000, 0.000000>,<0.000000, 0.000000, 0.000000>,-1.570796					]);			llRemoveInventory(llGetScriptName());		}		else{			llOwnerSay("This script works only with two, and exactly two, prims linked together");		}	}}

 

Thanks Innula, I've been using the twisted 1 prim version, I tried yours and got a bit better results, the twisted version doesn't seem to change unless I move but the 2 prim version does after a little time.  One of my ideas was to use this effect in a laboratory table as an x-ray scanner, the 2 prim version might give me more control over that.

Link to comment
Share on other sites


phaedra Exonar wrote:


Madelaine McMasters wrote:

You're shaming me with both your kindness and your generosity, LepreKhaun.

And pardon me for not noticing that was your debut post, Flint. Welcome aboard!

;-)

lol apparently no one here was shamed enough to reply to my last post so I deleted it.  May be I need to make a new alt every time I want to ask a question here.  Nothing personal Madelaine this comment is more directed to how the LSL forum seems to run.  Being nether new to sl, or a rl programmer, it seems hard for me to ask questions in a way that gets an answer on this forum. 

Ignored postings happen at times, no biggie. Sometimes it pays to be a bit patient because the expert that could answer just might not show up in the next hour or even the next day. Just be glad this wasn't yours- http://community.secondlife.com/t5/Fashion/Creating-a-ring-with-2-invisible-prims-that-resize/td-p/2349151 ;)

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3799 days.

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
 Share

×
×
  • Create New...