Jump to content

Texture swap script help please


FallenAngel Savira
 Share

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

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

Recommended Posts

I have 2 sculpted items that I have linked together and have put a texture, a transparent texture and the script in each and they both swap fine individually between the texture and the transparent. But what I want them to do is on touch one is invisible and one is showing texture and then touch again and they swap over so the invisible one shows and the other turns invisible. If that makes any sense to anyone

Link to comment
Share on other sites

It is too difficult to use two textures
Use just one, the visible and then use llSetLinkAlpha()

integer root = 1;default{    touch_end( integer n)    {        llSetLinkAlpha( 1+!root, 1.0, ALL_SIDES);        llSetLinkAlpha( 1+ root, 0.0, ALL_SIDES);        root = !root;    }}

That's all

:smileysurprised::):smileyvery-happy:

Note: This script will be in the root prim only, the child prim should be without a script

Link to comment
Share on other sites

Should the swapping happen when any part of the object is touched, or only when one of the swappable prims is touched? (or when only the visible one of the swappable prims is touched?)

This affects not only the script, but how many scripts you actually need. If any part can be touched, it's okay for the mouse cursor to change to show touchability anywhere over the object, so there can be just one script in the root prim. If not, then only the touchable child prim(s) should be in a script state that handles touch-related events (and in that case, the root prim really better not be one of the swappable prims).

Also, can the swappable prims have unique names or descriptions, so the script can find them no matter how the object gets linked?

And Dora is almost surely correct that you want to toggle alpha, not textures. There's a very subtle difference affecting right-click behavior, but it's very unlikely to be relevant here.

Link to comment
Share on other sites

I am making a childrens bed, i want the top blanket to seem to move on touch, i have a sculpt for the blanket as if the bed is neatly made and another sculpt where the blanket is screwed up and falling off the bed. I want to be able to touch the blanket and toggle between the 2 sculpts with the other one going out of sight. I have tried a sculpt changer script but it doesnt remember the positions or texture repeats. So i am trying it now with a texture changer so one goes to alpha and the other stays in sight. i only want it on touch with the blanket, the blankets will be linked to the beds but the mattress's on the beds have MLP menu's in. Hope this makes sense and Thank you very much both of you for trying to help :)

Link to comment
Share on other sites

That is not very hard to do
Here is a slightly different version of the script where you can set the link number values as you please

integer alpha = 1;integer prim1_LinkNumber = 1; // exampleinteger prim2_LinkNumber = 2; // exampledefault{    touch_end( integer n)    {        llSetLinkAlpha( prim1_LinkNumber,  (float)alpha, ALL_SIDES);        llSetLinkAlpha( prim2_LinkNumber, (float)(!alpha), ALL_SIDES);        alpha = !alpha;    }}

What Qie said about clicking is very wise and you should pay attention

The alpha toggling is independent of the texture on the prims, so you should just apply one fixed texture to each prim

:smileysurprised::):smileyvery-happy:

Link to comment
Share on other sites

  1. You have to figure out what link number each of your blankets are when it is all linked together and use those numbers in the script
  2. You can find the numbers by a helping script from an example here in the wiki

    When you have the numbers you can delete this script

  3. Feed the numbers to the script you had previously

    Keep the script in the root prim, that is simplest if it doesn't conflict with other scripts

:smileysurprised::):smileyvery-happy:

 

Link to comment
Share on other sites


i only want it on touch with the blanket, the blankets will be linked to the beds but the mattress's on the beds have MLP menu's in. 

I'd suppose that the mattress, where the MLP scripts are, is the root prim so that touching anywhere on the bed brings up the MLP menu. But we really don't want to wake up MLP when we're just toggling the blanket visibility, so we can't handle those touch events in the root prim (unless we change the MLP scripts to ignore touches from certain child prims).

Here's one approach. Put this script in each of the blanket prims, and be sure the "neat" blanket has the word "made" somewhere in its name, then reset scripts.

integer TOGGLE_BLANKET_MSG = -257634599;   // could be anythingstring SUBNAME_FOR_MADE_BED_BLANKET = "made";default{    state_entry()    {        if (~ llSubStringIndex(llToLower(llGetObjectName()),                SUBNAME_FOR_MADE_BED_BLANKET))            state visible;        else            state invisible;    }}state visible{    state_entry()    {        llSetLinkAlpha(LINK_THIS, 1.0, ALL_SIDES);    }    touch_end(integer total_number) // NOT touch_start (a very old bug)    {        llMessageLinked(LINK_ALL_OTHERS, TOGGLE_BLANKET_MSG, "", NULL_KEY);        state invisible;    }}state invisible{    state_entry()    {        llSetLinkAlpha(LINK_THIS, 0.0, ALL_SIDES);    }    link_message(integer sender_num, integer num, string str, key id)    {        if (TOGGLE_BLANKET_MSG == num)            state visible;    }}

Note that I've barely tested this, so scrutiny is warranted.

Also, if anything else besides touch (such as MLP) should make or unmake the bed, this should be done differently.

Link to comment
Share on other sites

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