Jump to content

Trying to change texture uuid of a certain prim in my boat.


woogalie
 Share

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

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

Recommended Posts

Hello everyone!

I have been searching and reading all over for how to make a script that will change textures for only the prim numbers I specify in my sailboat. 

Example - The sailboat's hull, deck and main sail is prim # 78, 79, 80, and I would like to drop a script into the boat that changes those textures to specific UUIDs I specify. 

 

This is mainly to sell my own custom sailboat textures for popular boats without giving away my UUIDs, so my customers can just drop a script into their boat and it changes the textures to the one they bought.

Thanks to everyone who points me in the right direction!

Woogalie~

Link to comment
Share on other sites

I advise you never to hard code prim numbers into your script.  If you add or remove links from the boat at any time, those numbers are likely to change.  To avoid the problem, name each of the prims. "Hull", "Deck", and "Sail" seem like logical names.  Then, let your script identify those links in state_entry ...
 

integer i;
while ( i < llGetNumberOfPrims() )
{
    ++i:
    string name = llGetLinkName(i);
    if (name == "Hull")
    {
        giHull = i;
    }
    else if (name == "Deck")
    {
        giDeck = i;
    }
    else if (name == "Sail")
    {
        giSail = i;
    }
}

where giHull, giDeck, and giSail are global integer variables that you have declared.  Then, apply the textures with either llSetLinkTexture or with llSetLinkPrimitiveParams, using those three variables as the link targets.  I would probably do that in state_entry as well, and would trigger everything by using a changed event to reset the script:
 

changed (integer change)
{
    if (change & CHANGED_OWNER)
    {
        llResetScript();
    }
}

I'd probably also reset the script on rez, just to be sure.

 

  • Like 3
Link to comment
Share on other sites

The two functions that are likely to be of most use to you are llSetLinkTexture and (as an alternative, and one which I think is probably better, though more complex) llSetLinkPrimitiveParamsFast.    The advantage to using llSetLinkPrimitiveParamsFast(linkNo,[PRIM_TEXTURE, various params]) is that you set the offset, scale and rotation in the same call.

However, I would echo Rolig's caution against relying on link numbers, since these can change.   I realise that you are thinking of selling your scripts for people to put in boats they've bought from others, which might lead you to think the link numbering is known.   However, since these boats are presumably modifiable (or your customers won't be able to drop the scripts into them) there's no way you can be sure that they won't have had the linking changed in some way, with the result that the texture that your customer thought would look  great as a flag is applied to the main deck,

To see why this is such a danger, rez three prims and link them together.   Drop this script in the root and note the numbering in the hovertext.    Then link another prim to the linkset, as a child.   Note what it does to the numbering, which may not be what you are expecting.    

Since the boat is mod, I think it's too dangerous to rely on the link numbering.   Better by far to use the link names  in the way Rolig suggests (even if you have to tell the customer to name the relevant prims).

default
{
    state_entry()
    {
       integer max = llGetNumberOfPrims()+1;
       integer counter = 1;
       do{
          llSetLinkPrimitiveParamsFast(counter,[PRIM_TEXT,(string)counter,<1.0,1.0,1.0>,1.0]);  
        }
        while(++counter < max);
    }

     changed(integer change)
     {
         if(change & CHANGED_LINK)
         {
            llResetScript();     
        }
    }
}

 

Edited by Innula Zenovka
  • Like 2
Link to comment
Share on other sites

If OP is selling textures for boats created by others (as I read the question - "This is mainly to sell my own custom sailboat textures for popular boats")..then prim determination may not be possible if 1) the user bought the boat from someone else (so prims aren't named), and 2) boat has been modified so prim numbers may not match OP's copy of the boat.

Link to comment
Share on other sites

I agree.  If the situation is that restricted, the OP has no options. However, if a boat owner does not have mod perms, he's not going to be the OP's customer in the first place.  There's no way that you can apply new textures to an object that you can't modify.  The owner won't be able to drop a script in it either. Therefore, Innula and I are assuming that the OP is marketing to people who do have mod perms on their boats and who can change link names and textures.

Edited by Rolig Loon
Link to comment
Share on other sites

Presumably the OP is trying out their textures on copies of boats they own, so they should be able to determine whether they've been scripted to use hard-coded link numbers or to determine link numbers from link names (or some other attribute) and adapt their applier scripts as necessary.

Link to comment
Share on other sites

Honestly, I've always had better luck applying textures by dragging and dropping them onto the faces I need them on. Texture mod application scripts can be a real booger.

It's too bad you can't just give people the textures themselves without someone trying to rip you off.

Edited by Berksey
Link to comment
Share on other sites

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