Jump to content

Texture change on linked objects?


Peires
 Share

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

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

Recommended Posts

Hi! So I'm making a product that relies on texture changing via a HUD.  However, I've run into a problem with the script that I'm using.  My mesh consists of several linked objects, but for some reason my mesh has two face 1s.  Because of this, the script changes both of those faces, even though they're two completely different faces that use different textures and are on two different linked objects.  Here is the script that's in both linked objects:

 

integer ch=(number);

default
{
state_entry()
{
llListen(ch,"",NULL_KEY,"");
}

listen(integer channel, string name, key id, string msg)
{
if (llGetOwner() == llGetOwnerKey(id))
{
llSetTexture(llGetSubString(msg,0,-1),1);
}
}
}

 

I believe incorporating llSetLinkTexture(LINK_THIS, could fix this problem, but I've tried adding it into the script (I'm honestly not too sure where to add it, so I've tried different places in the script) but I only get syntax errors.  Where could I add this into the script (if this is indeed what would make the script do what I would like it to) and still have the script compatible with the HUD?  Would I also need to add this into the HUD script?

 

Link to comment
Share on other sites

Hi Peires

I don't know how your hud works, but if you have a linked object, I think that you should change the line:

llSetTexture(llGetSubString(msg,0,-1),1);

by this:

llSetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXTURE, 1, llGetSubString(msg,0,-1)]);

The script have to be in the prim where you want to apply the texture.

 


If the script is working OK on single prim objects, then you'll just have to change this line to make it work with a linked object, and there's no need to modify the hud script.

 

Link to comment
Share on other sites

Thanks so much for replying!  I changed that line to llSetLinkPrimitiveParams(LINK_THIS, [PRIM_TEXTURE, 1, llGetSubString(msg,0,-1)]);, and didn't get any syntax errors, but when I pressed the corresponding button on the HUD, I received this error message: 

[20:00] llSetPrimitiveParams error running rule #1 (PRIM_TEXTURE): arg #3 (texture repeat) is missing. {RootName bitty head scripted, RootPosition { 74.0711, 89.0714, 3096.12 }}

Link to comment
Share on other sites

Thank you Rolig Loon, my mistake, I didn't remember that these values were mandatory when not modified.

And by the way, I saw that what I suggested is not the best way to do, llSetLinkTexture should do the trick more easely like Peires tried first. Here is the correct syntax in this case:
llSetLinkTexture(LINK_THIS, llGetSubString(msg,0,-1), 1);

and also, llGetSubString(msg, 0, -1) is not necessary, because it asks to get the sub string starting at first position of the string msg until the last character. I don't understand what it this for, it is the same as only msg.

So this line should work the same way:
llSetLinkTexture(LINK_THIS, msg, 1);

And it's less laggy.

 

Like Rolig pointed out, all parameters and syntax is explained on the SL Wiki LSL Portal, which is the best place to learn how to code in LSL. You can have a look to This page for instance, which shows all available functions available in LSL scripting, it is a good place to start.

But you also need to have some coding basics first, especially to understand what is a function and what is a parameter.

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...