Jump to content

What is wrong here.. " Name not defined within scope"


AnaZofia
 Share

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

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

Recommended Posts

I got an error message on this script: " Name not defined within scope", on the "if (primName == name) // check the name" line

What is wrong with the script?

 

SetATexture(string to, string from) 
{ 
    integer i;        // defaults to zero 
    integer j = llGetNumberOfPrims(); 

    for (; i < j; i++)   // scan over all prims from 0 to Number of Prims (1 or more) 
    { 
        string primName = llGetLinkName(i);    // get the name of the prim 
        if (primName == name)        // check the name 
        { 
            llSettexture(name, ALL_SIDES);        // set the alpha we were sent 
        } 
    } 
}

 

Link to comment
Share on other sites

Well... since you didn't include the entire script hard to say with 100% certainty, but, you likely didn't define your variables for "name", which you're checking against "primName".

 

Try adding:

string name;


at the very start of your script. Although, of course, if you do this primName is going to be compared against no name so you might want to include the name you're looking for... such as:

string name = "object";

or if you're actually just looking for the name 'name"... you should be able to get away with writing:

if (primName == "name")        // check the name 

(need quotes around name)

 

Although, I'm willing to bet what this script is intended to do is pull a the name of a texture from the prim contents, in which case, that is where you'd need to declare that variable at the start of the script then define it within the script by reading the prim's contents .

 

Hope this helps.

  • Like 1
Link to comment
Share on other sites


AnaZofia wrote:

I got an error message on this script: " Name not defined within scope", on the "if (primName == name) // check the name" line

What is wrong with the script?
SetATexture(string to, string from) {     integer i;        // defaults to zero     integer j = llGetNumberOfPrims();     for (; i < j; i++)   // scan over all prims from 0 to Number of Prims (1 or more)     {         string primName = llGetLinkName(i);    // get the name of the prim         if (primName == name)        // check the name         {             llSettexture(name, ALL_SIDES);        // set the alpha we were sent         }     } } 

As the error message says: some identifier(a name) is not defined inside a scope where it is referenced

In this case it looks like it is the variable named: name, not defined to be referenced inside the SetATexture-function

If you wonder about what a scope and an identifier is, take a look here. Nobody does it better

:smileysurprised::):smileyvery-happy:

  • Like 1
Link to comment
Share on other sites

As others have pointed out, there is a scoping problem with the use of name but there is a major error that has been overlooked- there is no such function named llSettexture and llSetTexture requires the name of the texture to apply to the prim the script resides within.
You really want to be using llSetLinkTexture, using i as your first parameter.

Link to comment
Share on other sites

My take on this :

SetATexture(string to, string from) {     integer i;        // defaults to zero     integer j = llGetNumberOfPrims();     for (; i < j; i++)   // scan over all prims from 0 to Number of Prims (1 or more)     {         string primName = llGetLinkName(i);    // get the name of the prim         if (primName == from)        // check the name         {             llSetLinkTexture(i,to, ALL_SIDES);        // set the alpha we were sent         }     } } 

You see, I think she is passing the string nameof the textures to replace and being replaced.

:)

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4057 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...