Checking if the touching av is seated on a specific object
|
|
Karl Gyranaut
Registered User
Join date: 21 Feb 2009
Posts: 8
|
02-24-2009 04:54
Sorry for the long title, I'm afraid the explanation might be just as wordy  I'm working on a script for a sort of tag game. The chaser will be riding a physical vehicle, and the people being chased will be wearing a prim target. The chaser is able to "tag" the people being chased by clicking the target. All this works swell. The trouble is that at the moment anyone can touch the target and it registers a tag. I can limit this some with groups but sooner of later someone who's not the chaser will get a click through. I know that the target prim can detect if an avatar is seated - which by itself isn't enough information since there might be people seated and not be the chaser - but is it possible for an object attached to one avatar to detect the name or UUID of the object on which another avatar is seated? Thanks
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
02-24-2009 05:45
There's probably a better way, but I think I would tackle if from a different angle. The target knows who has just touched it -- llDetectedKey(0) -- and the vehicle can grab the key of llAvatarOnSitTarget() when someone sits down. So couldn't the target, when someone touches it, say/shout on a suitably obscure negative channel "anyone got llDetectedKey(0) driving?" or words to that effect. If one of the vehicles shouts back that it has, then we know it's a fair tag.
|
|
Karl Gyranaut
Registered User
Join date: 21 Feb 2009
Posts: 8
|
02-24-2009 08:19
Hi Innula and thanks for answering
The trouble is that I may have several vehicles and even more people being chased in an area at once and I'm trying to shave as much lag as possible. I could limit the range since this should only work inside whisper range but the lagger would be all those llListens wouldn't it?
|
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
02-24-2009 11:17
I really don't know, but I wonder how much lag would actually be caused if you're using obscure negative channels unless lots of vehicles are participating in the game, particularly if they were using llRegionSay, it would seem, since that cuts out an unnecessary check on whether the speaking object is in hearing range -- see http://wiki.secondlife.com/wiki/LlListen#Notes However, it's a fair point, so how about doing it the other way round. All your vehicles repeatedly use llRegionSay to say "so and so is sitting on me" on a channel with a long negative number. When someone touches the target, the target grabs the av's key and opens a listener for a second or so. If it hears the key of the avatar who touched it, it records a hit. That way you only ever have one listener open, and very briefly at that. I don't know.. anyone who knows more about performance issues than do I (most people here, I suspect) have any suggestions? I can't think of any obvious alternatives to this approach.
|
|
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
|
02-24-2009 11:33
From: Karl Gyranaut Hi Innula and thanks for answering
The trouble is that I may have several vehicles and even more people being chased in an area at once and I'm trying to shave as much lag as possible. I could limit the range since this should only work inside whisper range but the lagger would be all those llListens wouldn't it? You would get more lag from multiple vehicles then listeners. Physical objects, and avatars tend to lag a sim more then listeners. As for how to check the key, and get that to the tagged prims. Really that's just a matter of how you want to set it up. Is the game dynamic? In other words, do you want someone joining in after you have started? If not, then just have a "start" prim, llRegionSay the list of taggers (you could send keys or names) and when the tagged items hear that, they can shut off the listener. Now if you make it dynamic, then you can do what Innula suggests. Or you could eliminate listeners all together, and use llHTTPRequest, or Email. Really it's just a matter of what you feel comfortable with. Just restrict the listeners as much as possible, and use a negative channel, and you should be fine 
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-25-2009 12:12
I'd probably have the vehicle announce when it has a driver. Then the targets can remember the key of the person who's "it" and immediately know whether a touch came from them or not.
Even a bunch of listeners on an "obscure" negative channel shouldn't generate a bunch of lag unless there is a bunch of chat traffic on that channel.
|
|
Karl Gyranaut
Registered User
Join date: 21 Feb 2009
Posts: 8
|
02-25-2009 12:14
My completely out of no where guess is between three and six vehicles at a time, and one to 15 people wearing the tag target prims. Naturally I'll turn out to be completely wrong <g>. So overall how does this sound: The vehicles use llSay with a channel number based on the pilot's UUID, and just basically keep saying "OK" or something else over and over. When the target prim is clicked it opens a listen on the same channel, based upon the touching avatar's UUID. If it hears "OK" on that channel then it knows that the person touching it is playing and registers a "tag". If it doesn't hear "OK" within a second it does nothing and kills the listener. So, two questions and I'll be out of your hair for good (yeah, right). First will constantly doing an llSay seriously effect the vehicle script? I've a timer in there for managing various functions so adding the llSay on a .5 second repeat is easy enough, I just don't want to wreck what's already working. Second, is there any advantage to further limiting the listener? I'll know the exact text I'm looking for - "OK" (or whatever I pick), and the key/UUID and name of the avatar touching the prim. Should I focus my llListen to: key toucher = llGetDetected(0); llListen(calculatedChannel, llKeytoName(toucher), toucher, "OK"  ; (sorry for any syntax errors, I'm at work and can't recall whether listens are msg then key, or key then msg). Thanks again
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
02-25-2009 13:17
That sounds like a heck of a lot of chats and listen start/stops. I think your original query/reponse idea was better. One channel. Send a query on touch with the toucher's key. Wait from a response from a vehicle, and timeout after a short period if none is received. Or have each vehicle send a message with the sitter's key (or NULL_KEY when the sitter stands up), and have each target keep an associative list of vehicle and sitter keys. On touch, use llGetObjectDetails() to make sure the vehicle is still around (if not, assume it has been deleted or something and that its sitter is no longer part of the game). If the vehicle is still around and has the toucher's key registered as its driver, accept the touch. Something like: integer VEHICLE_CHANNEL = -568086137;
list vechicleKeys = []; list driverKeys = [];
addVehicleDriver(key vehicle, key driver) { vehicleKeys += [ vehicle ]; driverKeys += [ driver ]; }
removeVehicle(integer index) { vehicleKeys = llDeleteSubList(vehicleKeys, index, index); driverKeys = llDeleteSubList(driverKeys, index, index); }
default { state_entry() { llListen(VEHICLE_CHANNEL, "", NULL_KEY, ""); ... }
listen(integer channel, string name, key id, string message) { if (channel == VEHICLE_CHANNEL) { integer vehicleIndex = llListFindList(vehicleKeys, [ id ]); if (vehicleIndex >= 0) { removeVehicle(vehicleIndex); }
key driverKey = (key)message; if (driverKey != NULL_KEY) { addVehicleDriver(id, driverKey); } }
... }
touch_start(integer nDetected) { integer i; for (i = 0; i < nDetected; ++i) { key toucherKey = llDetectedKey(i); integer driverIndex = llListFindList(driverKeys, [ toucherKey ]); if (driverIndex >= 0) { key vehicleKey = llList2Key(vehicleKeys, [ driverIndex ]);
if (llGetListLength( llGetObjectDetails(vehicleKeys, [ OBJECT_POS ])) < 1) { removeVehicle(driverIndex); } else { // Got a touch from someone who's "it"! } } } } }
|
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-25-2009 13:53
From: Karl Gyranaut The vehicles use llSay with a channel number based on the pilot's UUID, and just basically keep saying "OK" or something else over and over.
I'd do this: The vehicles use llRegionSay on a channel number known to the vehicle and the game controller, speaking the avatar's UUID when they sit, and NULL_KEY when they get up. The game controller keeps track of who is on what vehicle. The targets tell the game controller the toucher's UUID over another secret channel when they're touched. The game controller takes care of the scoring.
|