Jump to content

Texture Change Script Syntax Error


Reymundo
 Share

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

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

Recommended Posts


Reymundo wrote:

Still not doing anything, I really think I'm gonna have to revert it back to a
script per button
within the clothing prim. Trying to merge this into one script just doesn't seem to wanna work.

I'm increasingly confused by what you're trying to do. What object is this script supposed to go in? Are the buttons you mention HUD controls that you touch? If so, this is the wrong script for that button, as it's receiving commands, not sending them. If you have nothing in your system that's sending commands, nothing's going to happen in this script. If you do have something in your system that's sending commands (either in response to you touching something or clicking buttons in a menu), what is it? And where does this script go?

If this script goes into a clothing button for which you're trying to change the color and texture, it's still not going to work. llSetColor() and llSetTexture() change the properties of the prim they're in and nothing else. If you have three buttons, this script cannot control them all. It can only control the button it's inside. To make a single script control multiple prims (buttons) you'll have to collect them all together into a linkset, identify the link number of each button and then use llSetLinkColor() and llSetLinkTexture() to manipulate the color and texture of each button.

Link to comment
Share on other sites

Okay well let me reexplain it. The HUD that has 3 buttons (one for each face of the piece of clothing) has a script that sends commands to the clothing prim, which has the receiving script I'm trying to merge together. When I had 3 scripts of the receiving script in the clothing it accepted things perfectly fine. It's only when I had asked here for help in merging that receiving commands script that it stopped working. So what I'm getting is it's impossible for it to receive the commands unless there is an individual script for each. The following is one of the HUD buttons' scripts.

////////////////////////////////////////////////////////////////////////////////////// [ MESH WORKSHOP SCRIPTS ]/////////////////////////////////////////////////////////////////////////////////////////      integer ch=-13577;                                //Change this to a unique 5 digit number.key tex="272520de-0b34-9ffc-0abd-352548421b17";   //Texture UUID goes here.string txt="Applying, please wait...";            // Touch message goes here.//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////default{        touch_start(integer tn)    {        llSay(ch,tex);                key owner = llGetOwner();        llInstantMessage(owner,txt);     }} 

And this is the script that is in the receiving clothing item, as it stands.

////////////////////////////////////////////////////////////////////////////////////// [ MESH WORKSHOP SCRIPTS ]/////////////////////////////////////////////////////////////////////////////////////////      integer ch0=-13577;          //Same unique 5 digit number as controller.integer ch1=-13578;          //Same unique 5 digit number as controller.integer ch2=-13579;          //Same unique 5 digit number as controller.integer side = 5;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side2 = 6;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side3 = 3;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side4 = 2;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.key owner;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////default{    state_entry()    {        owner = llGetOwner();//set the global owner key        llListen(ch0,"","","");//set all the listens to listen to everything on the channel specified        llListen(ch1,"","","");        llListen(ch2,"","","");    }    listen(integer ch, string name, key id, string msg)    {      if(llGetOwnerKey(id) == owner)//is the speaking object owned by the same owner as this script?      {       if(ch==ch0)       {            llOwnerSay(msg);           llSetTexture(llGetSubString(msg,0,-1),side);           llSetColor(<0.5, 0.0, 0.0>, side );           llSetTexture(llGetSubString(msg,0,-1),side2);           llSetColor(<0.5, 0.0, 0.0>, side2 );       }      else if(ch==ch1)      {              llSetTexture(llGetSubString(msg,0,-1),side3);           llSetColor(<0.5, 0.0, 0.0>, side3 );       }             else if(ch==ch2)      {              llSetTexture(llGetSubString(msg,0,-1),side4);           llSetColor(<0.5, 0.0, 0.0>, side4 );       }    }   }//additional closing bracket for added test}
Link to comment
Share on other sites

Given your example, this is one way of sending the messages using a single script in the sender unit.

I'm assuming the three buttons are three prims, each linked to the main HUD prim.   First name them "Button 1", "Button 2" and "Button 3).

Then you can use a single script in the root prim to read the name of the prim someone touches, and decide which message and texture uuid to send, using a script something like this:

integer iChan0 = 13577;integer iChan1 = 13578;integer iChan2 = 13579;key kTexture1 = "272520de-0b34-9ffc-0abd-352548421b17";key kTexture2 = "uuid of some other texture";key kTexture3 = "yet another texture uuid";default{	touch_start(integer num_detected)	{		integer iChan;		key kTexture ="";		string str = llGetLinkName(llDetectedLinkNumber(0));//get the name of the prim that was touched		if ("Button 1"==str){//if the user touched the prim called "Button 1"			iChan = iChan0; //use iChan0 as the communication channel			kTexture = kTexture1;//and this as the texture		}		else if ("Button 2"==str){//if the user touched the prim called "Button 2"			iChan = iChan1; //use this			kTexture = kTexture2;		}		else if ("Button 3"==str){			iChan = iChan2;			kTexture = kTexture3;		}		if(iChan >0 && kTexture !=""){//sanity check to make sure we've got a channel and uuid			//send the message				llRegionSay(iChan, kTexture);//this way we don't have to worry about the range.  			//Also, possibly counter-intuitively, 			//llRegionSay and llRegionSayTo are the chat messages that are kindest on the simulator		}	}}

That's not the most elegant way of doing it, but it does, I hope, demonstrate the general method.

 

Link to comment
Share on other sites


Reymundo wrote:

Well I get the putting the sending scripts into one, but for some reason the texture stuff is stored in the receiving script. Just how Mesh Workshop did it.

It's certainly more efficient to it that way.

You can then use just the one channel and send a short message to the receiving script, depending on which button is pressed.   The receiver then uses logic on the lines of 

	listen(integer channel, string name, key id, string message)	{		if(message == "A"){			//do this		}		else if (message == "B"){			//do something different		}		else if (message == "C"){			//and so on		}	}
Link to comment
Share on other sites

integer ch=-100000; //same as buttons/HUD controlinteger side = 5;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side2 = 6;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side3 = 3;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.                            integer side4 = 2;   //Side to apply the texture to.                            // ALL_SIDES = All sides of the object.                            // Numbers 1-8 = Face number of the object.default{    state_entry()    {        llListen(ch,"",NULL_KEY,"");    }    listen(integer channel, string name, key id, string msg)    {        if (llGetOwner() == llGetOwnerKey(id))                { if (llGetSubString (msg, 0, 0) == "A")                {                      llSetTexture(llGetSubString(msg,1,-1),side);           llSetColor(<0.5, 0.0, 0.0>, side );           llSetTexture(llGetSubString(msg,1,-1),side2);           llSetColor(<0.5, 0.0, 0.0>, side2 );       }                     if (llGetSubString (msg, 0, 0) == "B")         {         llSetTexture(llGetSubString(msg,1,-1),side3);           llSetColor(<0.5, 0.0, 0.0>, side3 );}                       if (llGetSubString (msg, 0, 0) == "C")                {              llSetTexture(llGetSubString(msg,1,-1),side4);           llSetColor(<0.5, 0.0, 0.0>, side4 );       }                                                                             }    }}

Maybe I am missing something but I have no idea why multiple listeners are being used for this task.

 

The receiver script above is ready to go - you can work with innula's example to get the buttons into a single script if you want - otherwise the following script will work for button 1 and you just need to alter line 7 to derive your other buttons.

integer ch=-100000;  // same as receiverdefault{        touch_start(integer total_number)    {           llSay(ch,"A272520de-0b34-9ffc-0abd-352548421b17"); //Paste the UUID you wish to apply after letter A            //for button 2 replace letter A with B and insert your UUID as above           //for button 3 replace letter A with C and insert your UUID as above                  }}
Link to comment
Share on other sites

Hi, be sure to read and ponder Innula's advice about script logic because that information is applicable well beyond just this one specific task.

 

For this specific script I took out the multiple channels and replaced them with a single character code that is sent with the UUID.  The receiver script looks for the code using the following lines:

 

if (llGetSubString (msg, 0, 0) == "A")

 

 

 if (llGetSubString (msg, 0, 0) == "B")

 

 

if (llGetSubString (msg, 0, 0) == "C")

 The message sent from the button is a single character code followed immediately (no spaces) by the texture's UUID. 

Position 0,0, in a substring is the first character so (llGetSubstring (msg, 0, 0) is telling the script to look at the first character only.  

 

The receiver script then extracts the UUID in the same way as the code - by reading a subset of the string:

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

 In a substring 1 is the second character and -1 is the last, so the script will read everything in the substring except the first letter which in this case happens to be the UUID you supplied in your original example scripts but for this purpose could be any valid texture key you put in the button script.

Link to comment
Share on other sites

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