Jump to content

IFF listen Check for scripting.


Altier Verwood
 Share

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

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

Recommended Posts

Hello SL scripting  people me again! I have a question about a listen check, I'm trying  a  dozy of a thing and I want to know if it is even possible.

first off is the script. I want to  take this script a step farther. and have it check the name of the  object.

the  name is this 

CG REP Z-95 3.6

all my  objects match this naming convention with  a 3 letter tag just  after CG, I want to  make it so that  resupply checks that REP or IMP or SEP etc and only then will it accept the command.

but I can't figure out how to do a listen script so complex like that. would it be a while loop? I need a lot of help on this one.

 

string resupply_command="R1";

 listen(integer chn, string nam, key id, string msg)
    {
    if (msg == resupply_command && chn== -HIDDEN)
            {
        llSleep(1);
        //ammo_storeage = ammo_storeage_MAX;
        ammo_count = ammo_count_MAX ;
        llWhisper(0,damage_type +" Remaining Rounds "+(string)ammo_count);
            }
    }

Link to comment
Share on other sites

2 minutes ago, Profaitchikenz Haiku said:

Inside the listen event

If llGetSubString(name, 0, 5) == "CG REP") // is the name of the sending object in m class of names?

and then only process the heard text if the name of the sending object fits your naming pattern.

Oh man this looks like what I need, is there a way to make it automatically get the name from the object ?

If llGetSubString(llgetobjectname(), 0, 5) == "CG REP") kind of thing?

Link to comment
Share on other sites

2 minutes ago, Profaitchikenz Haiku said:

Yes, you can read the object name of the listener prim and extract the first 5 characters into a global variable "nameTag" and use that as the comparison.

Oh, could you elaborate a bit on that one? I've never done something like that.

Link to comment
Share on other sites

// outside the states we declare global variablees and functions

string nameTag;

// inside state_entry we read the object nname annd xtrat five characters as the nae tag

default
{
    state_entry()
	{
		nameTag = llGetSubString(llGetObjectName(), 0, 5);	// we will only action messages from other objects with this prefix in their name
	}

// then in the listen event
	listen(integer ch, string name, key id, string msg)
	{
		if( llGetSubString(namme, 0, 5) == nameTag)
		{
			// we hear and obey
		}
		// otherwise we do a van-gogh (turn a deaf ear) "I hear no sheeps"
	}

}

 

  • Thanks 1
Link to comment
Share on other sites

31 minutes ago, Profaitchikenz Haiku said:
// outside the states we declare global variablees and functions

string nameTag;

// inside state_entry we read the object nname annd xtrat five characters as the nae tag

default
{
    state_entry()
	{
		nameTag = llGetSubString(llGetObjectName(), 0, 5);	// we will only action messages from other objects with this prefix in their name
	}

// then in the listen event
	listen(integer ch, string name, key id, string msg)
	{
		if( llGetSubString(namme, 0, 5) == nameTag)
		{
			// we hear and obey
		}
		// otherwise we do a van-gogh (turn a deaf ear) "I hear no sheeps"
	}

}

 

I think I am still doing something wrong, it's still taking commands regardless of the sub string. here is the current code.

  state_entry()  
{
    llListen(-HIDDEN, "", "", "");
    nameTag = llGetSubString(llGetObjectName(), 0, 5);
    //llWhisper(0,damage_type +" Remaining Rounds "+(string)ammo_count);
}
       listen(integer chn, string nam, key id, string msg)
    {
    if (msg == resupply_command && chn == -HIDDEN&& llGetSubString(nam, 0, 5) == nameTag);
            {
        llSleep(1);
        //ammo_storeage = ammo_storeage_MAX;
        ammo_count = ammo_count_MAX ;
        llWhisper(0,damage_type +" Remaining Rounds "+(string)ammo_count);
            }
    }

 

Edited by Altier Verwood
Link to comment
Share on other sites

47 minutes ago, Rolig Loon said:

You don't need to check if( chn == -HIDDEN), because you've already filtered for the channel number in your llListen statement.   More than that, though, you don't want the semicolon at the end of that line. :) 

Why is it always a semicolon XD Thank you Rolig, saving my butt once again.

Link to comment
Share on other sites

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