Jump to content
  • 0

Can someone help me to change a touch menu script to a command listening script?


Cindy Kraai
 Share

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

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

Question

I got a script wherein when you put it on an object and touch it afterwards it gives you a menu that will change the texture of the object.

what i wanted to happen:

1. change the touch_start to something like listening to a command via local chat

2. or much better, to make a hud that will change the texture of the object (worn & rezzed)

 

thnks in advance for the replies!

 

here is the script btw:

integer side = ALL_SIDES;

list texture_list;
list texture_list2;
key user = NULL_KEY;

composelist()
{
integer currenttexture = 0;
integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE);

if(totaltextures > 0 & totaltextures <= 12)
{
texture_list = [];
do
{
texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
currenttexture++;
}
while (currenttexture > 0 & currenttexture < totaltextures);
}

if(totaltextures > 12 & totaltextures <= 22)
{
texture_list = ["Next Page"];
do
{
texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
currenttexture++;
}
while (currenttexture > 0 & currenttexture < 11);

texture_list2 = ["Last Page"];
do
{
texture_list2 = texture_list2 + llGetInventoryName(INVENTORY_TEXTURE, currenttexture);
currenttexture++;
}
while (currenttexture >= 11 & currenttexture < totaltextures);
}

if(totaltextures > 22)
{
llWhisper(0, "You may only have a maximimum of 22 Textures. Please remove any extra ones.");
}
if(totaltextures == 0)
{
llWhisper(0, "Please add up to 22 Textures inside this object.");
}
}


//The Menu
integer menu_handler;
integer menu_channel;
menu(key user,string title,list texture_list)
{
menu_channel = (integer)(llFrand(99999.0) * -1); //random channel
menu_handler = llListen(menu_channel,"","","");
llDialog(user,title,texture_list,menu_channel);
llSetTimerEvent(30.0); //menu channel open for 30 seconds
}

default
{
state_entry()
{
composelist(); //make list from inventory textures
}

touch_start(integer total_number)
{
user = llDetectedKey(0);
menu(user,"\n\nPlease select one below.",texture_list);
}

listen(integer channel,string name,key id,string message)
{
if (channel == menu_channel)
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
if(message == "Next Page")
{
menu(user,"\n\nPlease select one below.",texture_list2);
}
else if(message == "Last Page")
{
menu(user,"\n\nPlease select one below.",texture_list);
}
else
{
llSetTexture(message, side);
}
}
}

timer() 
{
llSetTimerEvent(0.0);
llListenRemove(menu_handler);
}

changed(integer change)
{
if (change & CHANGED_INVENTORY) //inventory has changed
{
llSleep(0.5);
composelist(); 
}
}
}

 

,,,

Sorry this is my first time to ask question in this forum i don't even know how to reply in it lol..

thank you for answering; however, im really lost cuz im not that really good in scripting, if its not too much can i have a step by step answer like:

1. This is the script for the texture worn or rezzed ["the script goes here"] 

2. This is the script for the hud ["the script goes here"]

sorry for being dumb on this  =(

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

A question like this really belongs in the LSL Scripting Forum, so I'm tempted to ask that it be moved.  However, it is just as easy to give you the guidance you're asking for here and it's a quiet afternoon. :smileywink:  Changing to a chat-activated system would be a clumsy move, so I'm glad that you prefer the HUD idea.  It's fairly simple to convert this script into a HUD controller, but you'll need to put a second script in your object to make it work.  Essentially, the HUD will do everything but apply the texture you have chosen, and the little script in your object will complete the job.

1. Unless you plan on putting a duplicate set of textures in your object --- not a good idea -- you should store all of the texture UUIDs in a couple of new global lists as you create texture_list and texture_list2.  Add them at the top of your script as list texture_UUIDs and list texture_UUIDs2.  Then build the lists by adding appropriate lines to your composelist function.

2. Then, in the listen event, you need a way to use the selected texture name as a way to retrieve the UUID that goes with that texture, and then send it to small script in the object.  The first part of this step is made a little more complicated by the fact that your script was not well written.  Even as written, if a texture name has more than 24 characters, the script will lock up and need to be restarted.  Fixing that means adding a little bit of code to the composelist function and then doing something similar in the listen event.  The second part just involves turning the llSetTexture statement into a llRegionSay statement.

The result could look something like this:

list texture_list;list texture_list2;list texture_UUIDs;list texture_UUIDs2;key user = NULL_KEY;integer gChan;composelist(){	texture_list = [];	texture_list2 = ["Last Page"];	texture_UUIDs = [];	texture_UUIDs2 = [0];	integer currenttexture = 0;	integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE);	if(totaltextures > 0 & totaltextures <= 12)	{		do		{			string temp = llGetInventoryName(INVENTORY_TEXTURE, currenttexture);			texture_list += [llDeleteSubString(temp, 23,-1)]; //Truncate texture name			texture_UUIDs += [llGetInventoryKey(temp)];	//Build UUID list			currenttexture++;		}		while (currenttexture > 0 & currenttexture < totaltextures);	}	else if(totaltextures > 12 & totaltextures <= 22)	{		texture_list = ["Next Page"];                texture_UUIDs = [0]; //Start with a null value in the list so it has the same length as texture_list		do		{			string temp = llGetInventoryName(INVENTORY_TEXTURE, currenttexture);			texture_list += [llDeleteSubString(temp, 23,-1)]; //Truncate texture name			texture_UUIDs += [llGetInventoryKey(temp)] ;	//Build UUID list			currenttexture++;		}		while (currenttexture > 0 & currenttexture < 11);		do		{			string temp = llGetInventoryName(INVENTORY_TEXTURE, currenttexture);			texture_list2 += [llDeleteSubString(temp, 23,-1)]; //Truncate texture name			texture_UUIDs2 += [llGetInventoryKey(temp)] ;	// Build extra UUID list			currenttexture++;		}		while (currenttexture >= 11 & currenttexture < totaltextures);	}	else if(totaltextures > 22)	{		llWhisper(0, "You may only have a maximimum of 22 Textures. Please remove any extra ones.");	}	else if(totaltextures == 0)	{		llWhisper(0, "Please add up to 22 Textures inside this object.");	}}//The Menuinteger menu_handler;integer menu_channel;menu(key user,string title,list texture_list){	menu_channel = (integer)(llFrand(99999.0) * -1); //random channel	menu_handler = llListen(menu_channel,"","","");	llDialog(user,title,texture_list,menu_channel);	llSetTimerEvent(30.0); //menu channel open for 30 seconds}default{	state_entry()	{		user = llGetOwner();  //This is a HUD, so the user will always be the owner.		gChan = (integer)("0xF" + llGetSubString(llGetOwner(),0,6)) + 78; //Create a random channel based on the owner's UUID		composelist(); //make list from inventory textures	}	touch_start(integer total_number)	{		menu(user,"\n\nPlease select one below.",texture_list);	}	listen(integer channel,string name,key id,string message)	{		string This_UUID;  //Here's where we're going to put the selected texture's UUID		llSetTimerEvent(0.0);		llListenRemove(menu_handler);		if(message == "Next Page")		{			menu(user,"\n\nPlease select one below.",texture_list2);		}		else if(message == "Last Page")		{			menu(user,"\n\nPlease select one below.",texture_list);		}		else		{			//I'm doing a trick here to save creating a new variable.  "channel" is already an integer variable			// and I don't really need it for anything else, so I'll overwrite it here and use it to find			// the UUID in one of the texture_UUID lists.			if (~(channel = llListFindList(texture_list,[message]))) //Is the message in texture_list?			{				This_UUID = llList2String(texture_UUIDs,channel); //If so, find its UUID in texture_UUIDs			}			else if (~(channel = llListFindList(texture_list2,[message]))) //Is the message in texture_list2?			{				This_UUID = llList2String(texture_UUIDs2,channel);	// If so, find its UUID in texture_UUIDs2			}			llRegionSay(gChan,This_UUID);	//And then tell the object which UUID to use		}	}	timer()	{		llSetTimerEvent(0.0);		llListenRemove(menu_handler);	}	changed(integer change)	{		if (change & CHANGED_INVENTORY) //inventory has changed		{			composelist();		}	}}

 EDIT:  Ooops.  There was a small error in setting up texture_UUIDs and texture_UUIDs2. :smileyembarrassed: I fixed it above.

 Then the script for the object you want to texture just looks like this:

default{    state_entry()    {        integer Chan = (integer) ("0xF" + llGetSubString(llGetOwner(),0,6)) + 78; // Same channel as in the HUD script        llListen(Chan,"","","");    }    listen (integer channel, string name, key id, string msg)    {        llSetTexture(msg,ALL_SIDES);    }}

 I can't get in world at the moment to test these, but they ought to work.  If not, they are close enough that you can patch them up to make them work with only a little poking.  I am assuming, BTW, that you are trying to texture objects that you own.  That's why I can use a communication channel derived from your own UUID in both scripts.

 

 

 

 

 

  • Like 1
Link to comment
Share on other sites

  • 0


Cindy Kraai wrote:

[ ... ]

Sorry this is my first time to ask question in this forum i don't even know how to reply in it lol..

thank you for answering; however, im really lost cuz im not that really good in scripting, if its not too much can i have a step by step answer like:

1. This is the script for the texture worn or rezzed ["the script goes here"] 

2. This is the script for the hud ["the script goes here"]

sorry for being dumb on this  =(

Sorry to be slow.  I just spotted your note. I thought it was pretty obvious, though.  The first script has to go in your HUD.  The second one is in whatever you are texturing.

You're right, BTW.  This Answers area was not set up for response and feedback, as a dialog.  It's really just one-way.  You ask a question; we respond.   Kinda dumb, I know.

Link to comment
Share on other sites

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