Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script Request to change Prim name

Aeryn Tuqiri
Registered User
Join date: 29 May 2008
Posts: 13
09-09-2008 02:23
Hello,

Been wondering if it is possible to add a script to a main prim of an object, and then trough chat you could verbally change the prim name.

for example, lets say you have a object made of 5 prims, main one having the name of Apple, and you want to name the prim Banana trough a command (not a normal object rename, needs to be trough a script).

So, would it be possible to make a script where you could type, lets say /4 name Banana, and it would change the name of only the prim containing the script?
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
09-09-2008 03:17
CODE


//Very Keynes - 2008

default
{
state_entry()
{
llListen(4,"","","");
}
listen(integer channel, string name, key id, string message)
{
integer x = llSubStringIndex(message,"name");
if(~x)llSetObjectName(llGetSubString(message,x + 5,-1));
}
}

Aeryn Tuqiri
Registered User
Join date: 29 May 2008
Posts: 13
09-09-2008 03:36
wow thanks ^^

Fast and working, this script will only change when the item owner uses it, right? or anyone that uses /4 name, can change the name?

Thank you so much, I had no idea it was possible =D
Very Keynes
LSL is a Virus
Join date: 6 May 2006
Posts: 484
09-09-2008 03:52
From: Aeryn Tuqiri
wow thanks ^^

Fast and working, this script will only change when the item owner uses it, right? or anyone that uses /4 name, can change the name?

Thank you so much, I had no idea it was possible =D


My Pleasure Aeryn.

It will work for anyone, if you want it to be owner only use this:

CODE


//Very Keynes - 2008

default
{
state_entry()
{
llListen(4,"","","");
}
listen(integer channel, string name, key id, string message)
{
if(llGetOwner() == id)
{
integer x = llSubStringIndex(message,"name");
if(~x)llSetObjectName(llGetSubString(message,x + 5,-1));
}
}
}



Which would allow you to test several keys if you wanted to ad a permisions list later, or this if it will always be owner only:

CODE


//Very Keynes - 2008

default
{
state_entry()
{
llListen(4,"",llGetOwner(),"");
}
listen(integer channel, string name, key id, string message)
{
integer x = llSubStringIndex(message,"name");
if(~x)llSetObjectName(llGetSubString(message,x + 5,-1));
}
}

Aeryn Tuqiri
Registered User
Join date: 29 May 2008
Posts: 13
09-09-2008 04:09
hehe =D I actually understood the additions, seems I am getting better in understanding LSL.

^^ thank you once again