Jump to content

Help needed with changing object name using a listener!


Gruff
 Share

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

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

Recommended Posts

Hey guys, basically I'm a really basic scripter, but learning!

Let me tell you a little about what i'm making, it's an alarm that when clicked, makes a sound, shouts a messege ect. Now i was looking for a way to give this out copy only, so the item would be no mod. The only problem with this is I intended this to be a personal item, like for a specific company our group. Say a group named 'Warscar Outlaws' had the alarm, I'd want them to have the option to customise it a little. Instead of the standard name and message, let's for this instance say it's name is 'Alarm' and it's message is 'The alarm has been rung!', I'd want them to have their own thing, like 'Warscar Alarm' for the name and 'Somebody has rung the dreaded Warscar alarm!'.

The way around this, I thought, would be to include an llSetObjectName and have it so that the listener detected the message on a certain channel. I thought about having the channels for the message and the name different, however it would be more professional if it was say /44 name (object name here) for the name, and /44 message (message here) for the message.

 

I've done this before on an unaccessable account (with help), so i know it IS possible. I seem to be struggling with taking the message from what's said, as I'm also having problems with a simple thing such as resetting. (I want the script to pick up when /44 reset is said, then it will reset the script and return it to it's default name and message, i already have this part, i just can't get it to reset on command!)

 

Mostly I'm having trouble with the listener, any help would be great!

Thanks in advance!

Link to comment
Share on other sites

Update, let me show you what i have so far:

 

string ObjectName;
string ShoutMessage;

default
{
    state_entry()
    {   //////////////////////////////////////////////////////////////////////
        ObjectName = "*>gG<* Raid'N'Trade Alarm Bell";
        ShoutMessage = "The Amarm Has Been Rung!";
        //Leave these, these will be used when the script is reset to defaults.
        //////////////////////////////////////////////////////////////////////
        llListen(44,"",llGetOwner(),"");
    }

    listen(integer channel, string name, key id, string message)
    {
        if (message==name + "")
        {
            llSetObjectName("");
        }
    }
}

Link to comment
Share on other sites

if (message==name + "")

Does this compile? it's looking for a string, you need the text in quotation marks as far as I'm aware, so:

if (message=="name" + "")

Unless name is a string variable of course, but I can't see that in the part of the script you posted. Although I'm not sure what the purpose of +"" is.

Also not sure what this would do:

llSetObjectName("");

 

 

Link to comment
Share on other sites

string gStrName = "Default Name";string gStrMessage "Default Message";default{    state_entry(){        llSetObjectName( gStrName );        llListen( 44, llGetOwner(), "", "" );    }        on_rez( integer vIntBgn ){        llSetObjectName( gStrName );     }//--works around a bug in worn items name's reverting        listen( integer vIntChn, string vStrNom, key vKeySrc, string vStrMsg ){        list vLstMsg = llParseString2List( llToLower( vStrMsg ), [" "], ["message", "name"] ); //-- reuse the chan integer we don't need to see which command is being requested        vIntChn = llListFindList( ["message", "name"], [llList2String( vLStMsg, 0)] );        if (~vIntChn){ //-- filter out -1 (it wasn't a command we have)            if (vIntChn){ //-- command is NOT index 0                gStrName = llStringTrim( llGetSubString( vStrMsg, 7, -1 ), STRING_TRIM );            }else{ //-- command must be index zero                gStrMessage = llStringTrim( llGetSubString( vStrMsg, 4, -1 ), STRING_TRIM );            }        }    }        touch_end( integer vIntTch ){        if (llGetOwner() == llDetectedKey( 0 )){            llShout( 0, gStrMessage );        }    }        changed( integer vBitChg ){        if (CHANGED_OWNER & vBitChg){            llResetScript();        }//-- reset on owner change to update default and listen to new owner    }}

 not checked for typos or logic errors

 

Link to comment
Share on other sites

Your script modified so it change the object name to what is said:

string ObjectName;string ShoutMessage;default{    state_entry()    {   //////////////////////////////////////////////////////////////////////        ObjectName = "*>gG<* Raid'N'Trade Alarm Bell";        ShoutMessage = "The Amarm Has Been Rung!";        //Leave these, these will be used when the script is reset to defaults.        //////////////////////////////////////////////////////////////////////        llListen(44,"",llGetOwner(),"");    }    listen(integer channel, string name, key id, string message)    {        llSetObjectName(message);    }}

 

Link to comment
Share on other sites

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