Skip to content

Instantly share code, notes, and snippets.

@rgooler
Created October 13, 2013 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgooler/6966576 to your computer and use it in GitHub Desktop.
Save rgooler/6966576 to your computer and use it in GitHub Desktop.
LSL population counter within distance
integer calcPopulation(){
// Setup variables
integer population = 0;
list avatars = llGetAgentList(AGENT_LIST_PARCEL,[]);
// See who is within range of the target
integer i = 0;
integer total = llGetListLength(avatars);
for(i;i < total; ++i){
key avatar = llList2Key(avatars,i);
string tmp = (string)llGetObjectDetails(llList2Key(avatars,i), [OBJECT_POS]);
vector avatar_at = (vector)tmp;
// See how many avatars are near the destination
if(llVecDist(DESTINATION, avatar_at) <= DESTINATION_SIZE){
++population;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment