Need help with llSensor running inside a loop to scan for specific keys.
|
|
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
|
01-20-2008 05:46
Hi, I'm sure the solution is easy, but I'm very new to scripting and have hit a wall. I have a script that loops through a list if Avatar Keys and determines if they are online and displays the name of those onlne. The part that matters is like this (I've removed extra bits to keep it simple); timer() { x=0; //reset counter statustext= "[Currently Online]\n"; timeroncheck= llRequestAgentData(llList2String(avi_keyid, x), DATA_ONLINE); } dataserver(key id,string data) { if(id == timeroncheck) { if(data == "1"  { statustext = statustext + llList2String(avi_name, x) + "\n"; \\ do other stuff in here to track status change for ONLINE avatars } else { \\Do stuff in here for those Ofline } if (x < llGetListLength(avi_keyid) - 1) { x++; timeroncheck = llRequestAgentData(llList2String(avi_keyid, x), DATA_ONLINE); } else { llSetText(statustext,<1,1,1>, 1.0); } } } Now this works fine, but I now want to do an additional step, when an avatar is detected as being ONLINE I want to then scan for them and if they are within the 96m show their distance after their name. I know (I think) I use llSensor() to do this, but this triggers an event which jumps me out of the loop above. So please, can somebody tell me how I should do this? Many thanks
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
01-20-2008 05:52
Move the if x < llGetListLength etc part into a function, and have it triggered by both the sensor() and no_sensor() events (since you may get either). Then have the dataserver event call llSensor to set the sensor off.
Or - you could save time by calling llSensor _once_, at the start of the check, and compiling a list of all of the avatars nearby, and their distance. This won't work well in crowded environments though, as you will only get the 14 closest avatars.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
01-20-2008 08:14
From: Ordinal Malaprop ...you will only get the 14 closest avatars. I think it's 16, isn't it? But in any case, is it essential to use a sensor? If not, llGetObjectDetails() using OBJECT_POS can tell where the online avatars are without needing a separate sensor event. (If I correctly understand the resolution to http://jira.secondlife.com/browse/SVC-774, llGetObjectDetails will get the 96m depth into adjacent sims when implemented. But someone close to that jira may know better.)
_____________________
Archived for Your Protection
|
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
01-20-2008 11:09
my understanding is tha the 96m limit is an absolute range from the calling object, regardless of sim borders... so that if the calling object is at 90m from the border, it'd only detect inward to the next sim a max of 6m. although comments by soft seem to be conflicting, so I'm not sure w/o testing.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
|
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
|
01-20-2008 19:31
From: Qie Niangao I think it's 16, isn't it? But in any case, is it essential to use a sensor? If not, llGetObjectDetails() using OBJECT_POS can tell where the online avatars are without needing a separate sensor event. (If I correctly understand the resolution to http://jira.secondlife.com/browse/SVC-774, llGetObjectDetails will get the 96m depth into adjacent sims when implemented. But someone close to that jira may know better.) Thanks, llGetObjectDetails is much easier! Somehow missed that  Am I correct that if the avatar is outside the current sim ,then <0,0,0> is returned instead of their real position? Is there ANY way of getting their REAL co-ordinates and using that to calculate the distance? I'd really like to know if somebody is in a neighbouring sim. Thanks
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
01-21-2008 10:41
From: Bones Outlander Am I correct that if the avatar is outside the current sim ,then <0,0,0> is returned instead of their real position?
Is there ANY way of getting their REAL co-ordinates and using that to calculate the distance? I'd really like to know if somebody is in a neighbouring sim. (Sorry: took me a while to get back to this. You know: "Oooo! shiny!"  ). The way it works now is to return the x,y coordinates relative to the corner of the sim in which the script is executing; so in other sims, those coordinates will be outside the range 0 to 256. That is, it does what you want: you can get distance, azimuth, and elevation directly from the offset. As far as I understand what's ahead, it will continue to do that, except not so deeply into neighboring sims (and even through a TP) like it does now. Ultra-simple scriptlet to play with this: default { state_entry() { llSetTimerEvent(5.0); } timer() { llOwnerSay((string)llList2Vector(llGetObjectDetails(llGetOwner(), [OBJECT_POS]), 0)); } }
_____________________
Archived for Your Protection
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-21-2008 11:13
Maybe not QUITE so simple. llOwnerSay() only (supposedly) works if you are in the same sim as the object. Might want to use llInstantMessage() for reliability instead. 
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
01-21-2008 11:40
From: Hewee Zetkin Maybe not QUITE so simple. llOwnerSay() only (supposedly) works if you are in the same sim as the object. Might want to use llInstantMessage() for reliability instead.  Good point. Actually, it follows you all around, as long as you've been in the same sim as the scripted object in the past few minutes. So either llInstantMessage, or have a short attention span. 
_____________________
Archived for Your Protection
|
|
Bones Outlander
Registered User
Join date: 16 Jan 2008
Posts: 30
|
01-21-2008 12:12
Thanks for the replies, but now I'm a little confused  I'm not near a SL client to test the script you gave me, but in my testing yesterday I found the following; My script runs as a HUD, so If I'm in Sim A and the avatar I'm monitoring is in say sim B, the llGetObjectDetails seems to be returning <0,0,0>. So in my script I check if the returned vector is <0,0,0> and then say "Outside Sim" or calculate the distance if <0,0,0> is not returned. Is this correct? Or could the llGetObjectDetails return another value other than <0,0,0> in the above case? Sorry if it's a silly question, I'm very new at all this scripting stuff  Bones
|
|
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
|
01-21-2008 13:25
llGetObjectDetails() can apparently continue to return data for an avatar that has left the region, but only for a very short period. There's something about the data not being updated as well. I'm not sure if that means it always reports the last position in the old region, or if it reports one single position in the new region, or what.
In any case, sensors CAN report objects and avatars outside the current region. The answer definitely applies to that data.
|