Jump to content

Need some help with touch script


Taaruf
 Share

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

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

Recommended Posts

Hello fellow sl players.

 

I need some help with my tail that has a touch script to it.

It appears that the name of the tail is shown in chat aswell if someone clicks on it for a message. 

For example, if someone choose the option "bite" when clicking, it would be somthing like.

 

Cat Tail 2.0 : (name) starts biting Taaruf's tail.

 

Would it be possible to make a quick little change so it would appear more like this.

 

(name) starts biting Taaruf's tail. (just skipping the name of the object techniqually)

 

Many thanks!

Link to comment
Share on other sites

Certainly.  Do the same thing that you do when you are typing that chat line yourself in world.  Instead of writing

llSay(0, Whoever + "  starts biting Taaruf's tail.");

write

llSay(0,"/me " + Whoever + "  starts biting Taaruf's tail.");

Adding \me at the start of any chat line suppresses the name of the speaker, whether you type it in world or write it in a script.

Link to comment
Share on other sites

Almost certainly, if you actually did cut and paste that line into your script.  After all, it would be dumb luck if there was somebody named Whoever in your script.   

Really, though, it just a matter of adding "/me " (complete with the quote marks and the space after me) at the start of whatever you want your object to say.  I have no way of knowing exactly what your own chat command look like, but you do.  So just add "/me " to whatever is there.

Link to comment
Share on other sites

The only different it made was , it removed the " : " 

Cat Tail : Taaruf bite Taaruf's Tail.

Cat Tail Taaruf bite Taaruf's Tail.

 

I want Cat Tail to disappear, so it simply says

 

Taaruf bite Taaruf's Tail.

Link to comment
Share on other sites

Ah.  Sorry.  I wasn't clear about what you were doing.  Then somewhere near the top of your script (a good place might be in the state_entry event), just change the name of your object.

llSetObjectName("");

That wil get rid of the name too.

Link to comment
Share on other sites

For an attachment, I would just change the name to that of the clicker in the touch event before responding. Then the "/me" will reflect the name of the toucher. Changing the name of an attachment while worn does not servive taking it back into inventory (its name will revert back to what it was originally). If it were for an object that is not attached, then a global value to hold its permanant name, set in the state_entry would be used, along with a user function to change its name, speak, and change it back. Since a tail is an attachment, the quick name change when touched should work fine.

ETA: Even a user function isn't absolutely needed in the other case, but might be a little more organized.

Link to comment
Share on other sites

It can't do that unless you typed llSetObjectName("New Object");

Just typellSetObjectName("");

As Erik says, a more elegant way is to change the name temporarily every time you click on the tail.  Still, changing it once at the top of the script should take care of the problem, assuming that the script resets when you attach the tail each time.

Link to comment
Share on other sites

Where do i exactly add llSetObjectName(""); ?

Let me show the script.

integer chan = -5;
list buttons;
integer listen_handle;
string firstname;
default
{
state_entry()
llSetObjectName("");
{
buttons = ["Bite","Pull"];
}
touch_start(integer total_number)
{
key id = llDetectedKey(0);
string name = llKey2Name(id);
firstname = llGetSubString(name,0,llSubStringIndex(name," "));
llDialog(id,"choose an action",buttons,chan);
listen_handle = llListen(-5, "","", "");
llInstantMessage( llGetOwner(), "**Touched by " + name );
}
listen( integer chan, string name, key id, string mess )
{

if(mess == "Pull")
{
llSay(0,"" + name + " Pulls Taaruf's Tail");
llDialog(id,"choose an action",buttons,chan);
llSetTimerEvent(20);
}
if(mess == "Bite")
{
llSay(0,"" + name + " Bites Taaruf's Tail");
llDialog(id,"choose an action",buttons,chan);
llSetTimerEvent(20);
}
}
timer()
{
llListenRemove(listen_handle);
llSetTimerEvent(0);
}
}

 

 

Link to comment
Share on other sites

Just like before, it only changes the object name to " New Object " and now it appears like this in chat.

 

New Object: Taaruf Resident Bites Taaruf's Tail

 

integer chan = -5;
list buttons;
integer listen_handle;
string firstname;
default
{
state_entry()
{
llSetObjectName("");
buttons = ["Bite","Pull"];
}
touch_start(integer total_number)
{
key id = llDetectedKey(0);
string name = llKey2Name(id);
firstname = llGetSubString(name,0,llSubStringIndex(name," "));
llDialog(id,"choose an action",buttons,chan);
listen_handle = llListen(-5, "","", "");
llInstantMessage( llGetOwner(), "**Touched by " + name );
}
listen( integer chan, string name, key id, string mess )
{

if(mess == "Pull")
{
llSay(0,"" + name + " Pulls Taaruf's Tail");
llDialog(id,"choose an action",buttons,chan);
llSetTimerEvent(20);
}
if(mess == "Bite")
{
llSay(0,"" + name + " Bites Taaruf's Tail");
llDialog(id,"choose an action",buttons,chan);
llSetTimerEvent(20);
}
}
timer()
{
llListenRemove(listen_handle);
llSetTimerEvent(0);
}
}

Link to comment
Share on other sites


Taaruf wrote:

Just like before, it only changes the object name to " New Object " and now it appears like this in chat.

 

New Object: Taaruf Resident Bites Taaruf's Tail

 

integer chan = -5;

list buttons;

integer listen_handle;

string firstname;

default

{

state_entry()

{

llSetObjectName("");

buttons = ["Bite","Pull"];

}

touch_start(integer total_number)

{

key id = llDetectedKey(0);

string name = llKey2Name(id);

firstname = llGetSubString(name,0,llSubStringIndex(name," "));

llDialog(id,"choose an action",buttons,chan);

listen_handle = llListen(-5, "","", "");

llInstantMessage( llGetOwner(), "**Touched by " + name );

}

listen( integer chan, string name, key id, string mess )

{

 

if(mess == "Pull")

{

llSay(0,"" + name + " Pulls Taaruf's Tail");

llDialog(id,"choose an action",buttons,chan);

llSetTimerEvent(20);

}

if(mess == "Bite")

{

llSay(0,"" + name + " Bites Taaruf's Tail");

llDialog(id,"choose an action",buttons,chan);

llSetTimerEvent(20);

}

}

timer()

{

llListenRemove(listen_handle);

llSetTimerEvent(0);

}

}

You could go about it this way: within your touch event, you are getting the name of the person touching the tail and you want the message said to be "So-and-so touched my tail". Right?

To do that, after you have gotten So-and-so's name, change the name of your object to their's and then use the /me emote.

 

integer chan = -5;list buttons;integer listen_handle;string firstname;default{	state_entry()	{		buttons = ["Bite","Pull"];	}		touch_start(integer total_number)	{		key id = llDetectedKey(0);		string name = llKey2Name(id);		firstname = llGetSubString(name,0,llSubStringIndex(name," "));		llSetObjectName(firstname);		llListenRemove(listen_handle);		listen_handle = llListen(chan, "","", "");		llDialog(id,"choose an action",buttons,chan);		llInstantMessage( llGetOwner(), "**Touched by " + name );	}	listen( integer chan, string name, key id, string mess )	{		llListenRemove(listen_handle);		llSetTimerEvent(0);		if(mess == "Pull")		{			llSay(0,"/me" + " Pulls Taaruf's Tail");		}		if(mess == "Bite")		{			llSay(0,"/me" + " Bites Taaruf's Tail");		}	}	timer()	{		llListenRemove(listen_handle);		llSetTimerEvent(0);	}}

 

[Edited to get listen_handle before opening llDialog and change backslashes]

Link to comment
Share on other sites

What is your script in, and how are you testing it?  It sounds as if you are messing with the script, detaching the tail, and then reattaching it.  That will of course rename the object without resetting the script.

This is not the place to come looking for a free script, but that one is so lousy that I'll write you a quick replacement now.  Here ....

integer gChan;integer gLsn;string gHold;string gFirstname;default{	attach (key id)	{		if (id)		{			llResetScript();		}	}		touch_start(integer num)	{		llListenRemove(gLsn);		gChan = -1 * (integer)llFrand(100000.0) + 100;		gLsn = llListen(gChan,"","","");		gFirstname = llGetDisplayName(llDetectedKey(0));		llDialog(llDetectedKey(0),"  \nChoose an action",["Bite","Pull"],gChan);		llOwnerSay( "**Touched by " + gFirstname );	}		listen( integer chan, string name, key id, string msg )	{		gHold = llGetObjectName();		llSetTimerEvent(0.0);		llSetObjectName("");		llListenRemove(gLsn);		integer idx = llListFindList(["Bite","Pull"],[msg]);		llSay(0,"/me " + gFirstname + llList2String([" bites "," pulls "],idx) + "Taaruf's tail");		llSetTimerEvent(20.0);		llSetObjectName(gHold);	}	timer()	{		llSetObjectName(gHold);		llListenRemove(gLsn);		llSetTimerEvent(0.0);	}}

 That's not tested in world, but should work.  And it should work much better than what you have.

Edit: Ooops.  I told you I hadn't tested it in world.  Removed a stray space.  It should be OK now.

Link to comment
Share on other sites

The scripts in a object? which is a tail attached to my avi.

 

Im using another avatar for clicking on it.

The result from the script you just wrote made it look like this in chat when clicking on it.

 

[14:09] Object: **Touched by Toi Toshi
[14:09] /me Toi Toshi bites Taaruf's tail

 

(other avatar would be Toi, clicking)

I dont really understand the confusion youre having, i want it to look like this in chat.

 

[14:09] Object: **Touched by Toi Toshi
[14:09] Toi Toshi bites Taaruf's tail

Link to comment
Share on other sites

This complicates a few things, i was use to the old script where you could changing around the messages as you wished, with this new script you made. how does that work? If i want more clicking options and a sentence instead of 1 word in difference.

 

Wouldnt it just be possible adding the only part that made the object name disappear in chat. To the script i had? That would be perfect.

Link to comment
Share on other sites


Taaruf wrote:

So how do i add a line of message for each category in the script you wrote?

 

Bite 

(name) bites Taaruf's Tail.

 

Cut 

Taaruf's tail was cut off by (name) and thrown in the trash

 

etc

If you take the time to study the code examples given you until you understand why they accomplish what they do, you'll be able to answer your own question.

Link to comment
Share on other sites

There are many ways to create these, but when you add options, it gets a little bit more complicated each time.

I wrote a simple one but left it alone since you had a lot of responses. Simple verbs in the button list will work as it is, but for something like "Cut off" to be turned into "cuts off" in the response, you have to do a little more work with the strings in the listen event responses.

integer channel;integer listener;float time = 0.0;string user;string owner;//Global list not needed in this simple form, but easy to customizelist buttons = ["Bite","Pull","CANCEL"];//I only drop a last name if it is Residentstring dropResident(string name){    integer index = llSubStringIndex(name, " Resident");//Be sure the blank space is there.    if (index > 0)    {        name = llDeleteSubString(name, index, -1);    }    return name;}default{    state_entry()    {        owner = dropResident(llKey2Name(llGetOwner()));        channel = (integer)(llFrand(-1000000000.0) - 1000000000.0);//Don't listen to anyone else's tail        llSetMemoryLimit(9000); //If you change the script - repair this    }    touch_start(integer total_number)    {        if (time)   //Wait their turn - don't listen to answer        {            llDialog(llDetectedKey(0),"\n\n" + user + " is playing with " + owner + "'s tail.",["OK"],channel + 1);            return;        }        key id = llDetectedKey(0);        user = dropResident(llKey2Name(id));        llSetObjectName(user);        llDialog(id,"\n\nChoose an option:",buttons,channel);        listener = llListen(channel,"",id,"");        llSetTimerEvent(time = 20.0);    }    listen(integer channel,string name,key id,string msg)    {        llListenRemove(listener);        llSetTimerEvent(time = 0.0);        msg = llToLower(msg);        if (msg != "cancel")        {            llSay(0,"/me " + msg + "s " + owner + "'s tail.");            llDialog(id,"\n\nChoose an option:",buttons,channel);            listener = llListen(channel,name,id,"");            llSetTimerEvent(time = 20.0);        }    }    timer()    {        llSetTimerEvent(time = 0.0);        llListenRemove(listener);    }    attach(key id)    {        llResetScript();    }}

 

ETA: You can check value for id in the attach event as in Rolig's script if you prefer - this will reset both on attach and detach.

Link to comment
Share on other sites

It is an attachment. A lot of places check memory limits on avatar attachments now days. Give them a fairly accurate figure instead of looking bloated. I checked using llGetUsedMemory() at the end of the listen event - 8812 as is, a little lower when checked from timer. Without the limit, it appears as a full 64k to other scripts that are checking - 8 times higher than it is.

Link to comment
Share on other sites

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