Jump to content

Change touch_start to owner chat command


Napili Sands
 Share

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

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

Recommended Posts

Hi Napili,

The script is already listening for commands from the menu, so you can chat to it. The only problem is that the makeMenu function assigns a random chat channel for the menu handler. If you replace the menuChan assignment with a constant, you can then chat on that channel and give the same commands as the menu.

For example, to send commands on channel seven, you'd change...

menuChan = 50000 + (integer)llFrand(50000.00);

to

menuChan = 7;

Typing /7 MIN SIZE in the chat window would then cause the object to scale itself to minimum size.

 

Link to comment
Share on other sites

Changing the channel to 7 works, but if I remove touch_start, or even just comment out  the one line

if (llDetectedKey(0) == llGetOwner()) makeMenu();

in touch_start,  chat commands no longer work.

I have another script that responds to touch, so I need to remove that from the resizer script.

Link to comment
Share on other sites

If you want your object to respond only to chat commands, you can eliminate the makeMenu function, but only after moving the lines that start listening for your chat.

Those two lines are:

menuChan = 7; //(or whatever channel number you choose)
handle = llListen(menuChan,"",llGetOwner(),"");

Move those two lines to inside the if(scanLinkSet) section of state_entry(), right after the //llOwnerSay("resizer script ready"); line, so they will start the script listening right away. Once you've moved those two lines you should be able to remove the makeMenu function and the touch_start event handler.

 

Link to comment
Share on other sites

I've edited the code to set the menu channel number at the script's compile time and I've removed the makeMenu function and touch_start handler. I haven't tested this, so caveat emptor. If it doesn't work for you, I'll pop in-world later and make it right.

 

// Linkset Resizer with Menu// version 1.00 (25.04.2010)// by: Brilliant Scientist// --// This script resizes all prims in a linkset, the process is controlled via a menu.// The script works on arbitrary linksets and requires no configuration.// The number of prims of the linkset it can process is limited only by the script's memory.// The script is based on "Linkset Resizer" script by Maestro Linden.// http://wiki.secondlife.com/wiki/Linkset_resizer// This script still doesn't check prim linkability rules, which are described in:// http://wiki.secondlife.com/wiki/Linkability_Rules// Special thanks to:// Ann Otoole float MIN_DIMENSION=0.01; // the minimum scale of a prim allowed, in any dimensionfloat MAX_DIMENSION=10.0; // the maximum scale of a prim allowed, in any dimension float max_scale;float min_scale; float   cur_scale = 1.0;integer handle;integer menuChan = 7; // set this to whatever suits you. I'd avoid 1, lots of scripts use that channel. float min_original_scale=10.0; // minimum x/y/z component of the scales in the linksetfloat max_original_scale=0.0; // minimum x/y/z component of the scales in the linkset list link_scales = [];list link_positions = [];  integer scanLinkset(){	integer link_qty = llGetNumberOfPrims();	integer link_idx;	vector link_pos;	vector link_scale; 	//script made specifically for linksets, not for single prims	if (link_qty > 1)	{		//link numbering in linksets starts with 1		for (link_idx=1; link_idx <= link_qty; ++link_idx)		{			link_pos=llList2Vector(llGetLinkPrimitiveParams(link_idx, [PRIM_POS_LOCAL]),0);			link_scale=llList2Vector(llGetLinkPrimitiveParams(link_idx,[PRIM_SIZE]),0); 			// determine the minimum and maximum prim scales in the linkset,			// so that rescaling doesn't fail due to prim scale limitations			if(link_scale.x<min_original_scale) min_original_scale=link_scale.x;			else if(link_scale.x>max_original_scale) max_original_scale=link_scale.x;			if(link_scale.y<min_original_scale) min_original_scale=link_scale.y;			else if(link_scale.y>max_original_scale) max_original_scale=link_scale.y;			if(link_scale.z<min_original_scale) min_original_scale=link_scale.z;			else if(link_scale.z>max_original_scale) max_original_scale=link_scale.z; 			link_scales    += [link_scale];			link_positions += [link_pos];		}	}	else	{		llOwnerSay("error: this script doesn't work for non-linked objects");		return FALSE;	} 	max_scale = MAX_DIMENSION/max_original_scale;	min_scale = MIN_DIMENSION/min_original_scale; 	return TRUE;} resizeObject(float scale){	integer link_qty = llGetNumberOfPrims();	integer link_idx;	vector new_size;	vector new_pos; 	if (link_qty > 1)	{		//link numbering in linksets starts with 1		for (link_idx=1; link_idx <= link_qty; link_idx++)		{			new_size   = scale * llList2Vector(link_scales, link_idx-1); 			if (link_idx == 1)			{				//because we don't really want to move the root prim as it moves the whole object				llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size]);			}			else			{				new_pos    = scale * llList2Vector(link_positions, link_idx-1);				llSetLinkPrimitiveParamsFast(link_idx, [PRIM_SIZE, new_size, PRIM_POSITION, new_pos]);			}		}	}} default{	state_entry()	{		if (scanLinkset())		{			handle = llListen(menuChan,"",llGetOwner(),"");			//llOwnerSay("resizer script ready");		}		else		{			llRemoveInventory(llGetScriptName());		}	}  	listen(integer channel, string name, key id, string msg)	{		//you can never be too secure		if (id == llGetOwner())		{			if (msg == "RESTORE")			{				cur_scale = 1.0;			}			else if (msg == "MIN SIZE")			{				cur_scale = min_scale;			}			else if (msg == "MAX SIZE")			{				cur_scale = max_scale;			}			else if (msg == "DELETE...")			{                                           llDialog(llGetOwner(),"Are you sure you want to delete the resizer script?",                            ["DELETE","CANCEL"],menuChan);                           return;							}							else if (msg == "DELETE")			{                                           llOwnerSay("deleting resizer script...");			   llRemoveInventory(llGetScriptName());							}						else			{			    cur_scale += (float)msg;			} 			//check that the scale doesn't go beyond the bounds			if (cur_scale > max_scale) { cur_scale = max_scale; }			if (cur_scale < min_scale) { cur_scale = min_scale; } 			resizeObject(cur_scale);		}	}}

 

Link to comment
Share on other sites

Thanks for your help.  I needed the menuMaker subroutine, since I don't want to issue menu commands from chat, I want the menu to pop up with a chat command. I added a conditional to check for the chat command "resize" to invoke menuMaker in the listen subtoutine and an additional menuMaker call at the end of the resizeObject subroutine to keep the menu up until the user is finisher resizing.

 

 

Link to comment
Share on other sites

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