Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Chat Commands

Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
02-13-2008 10:27
I would like to type a chat command for a "master" object and have it search to see if all the "slave" objects it's looking for are within 20 meters.

When the "slave" objects "hear" the "master", they will reply back over chat each with it's own identifier.

This will not be a heavily used command.

Wiill the following (under listen) be able to determine if "all" the "slaves" are nearby and then perform a function?

All help will be greatly appreciated! :-)

CODE

{
if(message == "Auto On")
llSay(8, "All?");
llSay(0, "Looking for All Slave Objects");
}

{
if ((message == "Yes2") &
(message == "Yes3") &
(message == "Yes4") &
(message == "Yes5") &
(message == "Yes6") &
(message == "Yes6"))
AutoSequence();
else
llSay(0, "Cannot Initiate Auto Mode: Not All of the Seven Slave Objectsare within 20 Meters.");

}
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-13-2008 10:44
What you want to do is a little different than you have written; since the responses will come in at different times, you need to check whether you have them all every time a message is received, which is what I think you're trying to do, so you should be on the right track.

But to actually do this, you need to keep track of which have responded in a variable. If you have less than 32 of them, you can use a single integer (woo!), otherwise you may need a string or a list. When you get a response, you add that response to your variable if it's valid and check to see whether the variable says all are received. So, since you have 7 slaves, and assuming their responses are "Yes1" to "Yes7", I'd do something like this:

CODE

integer responses = 0;

{
if (llGetSubString(msg, 0, 2) == "Yes") {
responses = responses | (1 << (integer)llGetSubString(msg, 3, -1)); // set the bit for this slave to true
if (responses == 254) {
// all responses received, do stuff, set responses to 0 again
}
}
}
_____________________
Zena Juran
Registered User
Join date: 21 Jul 2007
Posts: 473
02-13-2008 12:34
Thanx Tyken :-)

I'm not that good with strings but I almost got the gist of this. So If I have 6 "slaves" and 6 only, each with a unique Identifier (1-6), this will be able to determine that all 6 different ones are there? I'm trying to make sure all 6 unique slaves are present not just a total of 6 that will give a response. :-)
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
02-13-2008 12:54
Yes, but if you want to do only six, the one line should be if (responses == 126) instead.
_____________________