Jump to content

Ares Halostar

Resident
  • Posts

    99
  • Joined

  • Last visited

Reputation

2 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thanks for all the suggestions. I finally got this thing to report in the format I needed. Whilst I use the make notecard function to save the results, in LSL you will need to direct the output the way you need to. If you wish to use it for a normal 256 sized region, you will have to adjust the Max scan float to 256 instead of 512. Here is the script that works for me: list gListCountsAndOwners; // Sorted list count+owner pairs integer gOffset; integer gIndex; integer gListLength; list gPrclID; integer gTotPrims; integer gNUM; float gX; float gY; CalcPrims(vector Loc) { list TempList = llGetParcelPrimOwners(Loc); gListLength = llGetListLength(TempList); if (!gListLength) { llSetText("[ERROR]\n Couldn't get Parcel Prim Owners", <1,0,0>, 1); } else { // Produce a copy of the list suitable for sorting by count, i.e. count then key integer x; for ( ; x < gListLength; x += 2) { string owner = osKey2Name(llList2Key(TempList, x)); integer count = llList2Integer(TempList, x + 1); integer index = llListFindList(gListCountsAndOwners, [owner]); if (index % 2 == 1) // make sure the find is in column 2. owner name might be a number { // prim owner is in list, so update --index; // decrement to point to prim count count += llList2Integer(gListCountsAndOwners, index); gListCountsAndOwners = llListReplaceList(gListCountsAndOwners, [count], index, index); } else { // prim_owner is not in list, so append gListCountsAndOwners += [count, owner]; } } //llOwnerSay(llList2CSV(gListCountsAndOwners)); } } default { state_entry() { llSetText("Show Prim Owners\nTouch to scan region", <1,1,1>, 1); gListCountsAndOwners=[]; } touch_start(integer total_number) { llSetText("Scanning...\n", <1,1,0>, 1); gPrclID = []; gTotPrims = 0; // Start scan in the SW corner of the sim gX = 4.0; gY = 4.0; gNUM = 0; integer i; for (i = 0; i < 4096; i++) { list parcel = llGetParcelDetails(<gX,gY,100.0>,[PARCEL_DETAILS_ID,PARCEL_DETAILS_NAME]); key temp = llList2Key(parcel,0); // The parcel's UUID string parcel_name = llList2String(parcel,1); // The parcel's name if (parcel_name == "") { parcel_name = "(no name)"; } if (!~llListFindList(gPrclID,[temp])) // Have we scanned this parcel before? { ++gNUM; llSetText("Processing Parcel:\n"+(string)parcel_name,<0,1,0>,1.0); CalcPrims(<gX,gY,100.0>); gPrclID += [temp]; } if (gX < 512.0) // Increment X but don't let X go outside the sim borders { gX +=8.0; } if (gX > 512.0) // If it does, reset X and increment Y { gY += 8.0; gX = 4.0; } if (gY > 512.0) // Don't let Y go outside the sim boders. If it does, wrap up the scan .... { string NCname = llGetRegionName(); string ReportName = "## Region: "+(string)NCname+" - Total Parcels: "+(integer)gNUM+"\n"; gListCountsAndOwners = llListSort(gListCountsAndOwners, 2, FALSE); integer Length = llGetListLength(gListCountsAndOwners); integer z; integer Inc; string Output; for ( ; z < Length; z++) { Inc+=1; Output+=(string)llList2String(gListCountsAndOwners,z); Output+=" "; if(Inc==2) { Output+="\n"; Inc=0; } } osMakeNotecard(NCname, ReportName+"\n"+Output); llOwnerSay("Total Parcels: "+(integer)gNUM+"\nReport Notecard "+(string)NCname+" saved to prim inventory"); gListCountsAndOwners=[]; llSetText("Show Prim Owners\nTouch to scan region", <1,1,1>, 1); } } } } Thanks again for all the help.
  2. While this works in SL, I need it to work in Opensim as well, and llListSortStrided is not supported as yet. Basically what I am trying to achieve, is to scan a region's parcels, and find out how many prims the avatars are using on that region. I will attach the code that I am experimenting with now. list gListCountsAndOwners; // Sorted list count+owner pairs list gListNamesAndCounts; // List of owner names + prim counts integer gOffset; integer gIndex; key gDataserverID; integer gListLength; list gPrclID; integer gTotPrims; integer gNUM; float gX; float gY; list NameList; CalcPrims(vector Loc) { list TempList = llGetParcelPrimOwners(Loc); gListLength= llGetListLength(TempList); if (!gListLength) { llSetText("[ERROR]\n Couldn't get Parcel Prim Owners", <1,0,0>, 1); } else { // Produce a copy of the list suitable for sorting by count, i.e. count then key integer x; for ( ; x < gListLength; x += 2) { gListCountsAndOwners += llList2Integer(TempList, x+1); gListCountsAndOwners += osKey2Name(llList2Key(TempList, x)); } } } default { state_entry() { llSetText("Prim Owners\n", <1,1,1>, 1); gListCountsAndOwners=[]; NameList=[]; } touch_start(integer total_number) { llSetText("Scanning...\n", <1,1,0>, 1); gPrclID = []; gTotPrims = 0; // Start scan in the SW corner of the sim gX = 4.0; gY = 4.0; gNUM = 0; list TEMPLIST; TEMPLIST+="## Region: "+(string)llGetRegionName()+"\n"; integer i; for (i = 0; i < 4096; i++) { list parcel = llGetParcelDetails(<gX,gY,100.0>,[PARCEL_DETAILS_ID,PARCEL_DETAILS_NAME]); key temp = llList2Key(parcel,0); // The parcel's UUID string parcel_name = llList2String(parcel,1); // The parcel's name if (parcel_name == "") { parcel_name = "(no name)"; } if (!~llListFindList(gPrclID,[temp])) // Have we scanned this parcel before? { ++gNUM; llSetText("Processing \n"+(string)parcel_name,<0,1,0>,1.0); CalcPrims(<gX,gY,100.0>); gPrclID += [temp]; } if (gX < 512.0) // Increment X but don't let X go outside the sim borders { gX +=8.0; } if (gX > 512.0) // If it does, reset X and increment Y { gY += 8.0; gX = 4.0; } if (gY > 512.0) // Don't let Y go outside the sim boders. If it does, wrap up the scan .... { //Tally List //Sort List gListCountsAndOwners = llListSort(gListCountsAndOwners, 2, FALSE); string NCname = llGetRegionName(); osMakeNotecard(NCname,gListCountsAndOwners); //Create Notecard with data llOwnerSay("Total Parcels: "+(integer)gNUM); FinalOutput(); gListCountsAndOwners=[]; NameList=[]; llSetText("Touch to start scan",<1.0,1.0,0.0>,1.0); } } } }
  3. I have a list of data that basically gives an integer, and avatar name. The integer is the result of how many prims an avatar may have on a given parcel. But my avatar and others are repeated in the list several times and with different amounts (as I own several parcels on that region) ie: 1367, Ares Halostar, 456, Drongo Bonk, 325, Ares Halostar, 345, Mr Zonk, 567, Drongo Bonk My name appears twice, as does another, but I want to total the integers and create a new list: 1692, Ares Halostar, 1023, Drongo Bonk, 345, Mr Zonk. Lists always do my head in, even though this is a simple 2 strided list. Please can someone work out a quick routine for me to use ? Thanks in advance.
  4. It works, not as smooth as I'd hoped, but with some fine tuning I will get there. I had to divide by the root rotation TWICE to get the result I wanted with the upper prim. The final code is below: integer getLinkNum(string primName) { integer primCount = llGetNumberOfPrims(); integer i; for (i=0; i<primCount+1;i++) { if (llGetLinkName(i)==primName) return i; } return FALSE; } rotation TurnTowards(vector pos) { vector this = llGetPos() + <0, 0, 0.75>; // Calculate the base (left/right rotation) vector direction = llVecNorm(pos - this); direction.z = 0; rotation final = llRotBetween(<1,0,0>, direction); // Calculate the turret (up/down rotation) float dist = llVecDist(<pos.x, pos.y, 0>, <this.x, this.y, 0>); rotation pitch = llRotBetween(<1,0,0>, llVecNorm(<dist, 0, pos.z - this.z>)); // Set both values llSetLinkPrimitiveParamsFast(getLinkNum("Main"), [PRIM_ROTATION, final, PRIM_LINK_TARGET, getLinkNum("UpDown"), PRIM_ROTATION, pitch * final/llGetRootRotation()/llGetRootRotation()]); // This is used later for rezzing return pitch * final; } default { state_entry() { llSensorRepeat("", "", AGENT, 96.0, PI,1.0); } sensor(integer num_detected) { TurnTowards(llDetectedPos(0)); } }
  5. integer getLinkNum(string primName) { integer primCount = llGetNumberOfPrims(); integer i; for (i=0; i<primCount+1;i++) { if (llGetLinkName(i)==primName) return i; } return FALSE; } rotation TurnTowards(vector pos) { vector this = llGetPos();// + <0, 0, 1.06>; // Calculate the base (left/right rotation) vector direction = llVecNorm(pos - this); direction.z = 0; rotation final = llRotBetween(<1,0,0>, direction); // Calculate the turret (up/down rotation) float dist = llVecDist(<pos.x, pos.y, 0>, <this.x, this.y, 0>); rotation pitch = llRotBetween(<1,0,0>, llVecNorm(<dist, 0, pos.z - this.z>)); // Set both values llSetLinkPrimitiveParamsFast(getLinkNum("Main"), [PRIM_ROTATION, final, PRIM_LINK_TARGET, getLinkNum("UpDown"), PRIM_ROTATION, pitch * final]); // This is used later for rezzing return pitch * final; } default { state_entry() { llSensorRepeat("", "", AGENT, 96.0, PI,1.0); } sensor(integer num_detected) { TurnTowards(llDetectedPos(0)); } } That is the code I am using, and it nearly works, the bottom prim "Main" turns as it should, but the top prim "UpDown" doesn't quite do what it is required and ends up at a different angle as per the photo:
  6. I have two Prims. The bottom one points one face to an avatar (disregarding avatars height, so it only tracks left and right). That simple code is: default { state_entry() { llSensorRepeat("", "", AGENT, 96.0, PI,1.0); } sensor(integer num_detected) { vector Pos = llDetectedPos(0); vector MyPos = llGetPos(); vector target_posA = <Pos.x, Pos.y, MyPos.z>; llRotLookAt(llRotBetween(<1.0, 0.0, 0.0>,llVecNorm(target_posA-MyPos)), 1.0, 0.1); } } That works fine. The linked child prim above it, I want it to point to the avatar as well, but not only with the left and right movement, but also up and down. Seems like a simple thing to accomplish, but rotations have always done my head in. As an example, think of a rocket launcher rotating on a base, with the actual rocket tube tracking up and down while the base moves around on it's own axis.
  7. Thanks panterapolnocy for your reply, and yes, that fixed my problem. For anyone else interested, this was for moving a clone that I had made in Opensim. But it could be applied to a primset as well. That is why I couldn't use other movement solutions.
  8. llMoveToTarget has a limitation of 65m, but I need to move something over that distance, and it can be hundreds of metres away. I know how to calculate the amount of "hops" needed, if I break it up to 50m movements. But how to do calculate the positions that the project needs to travel to. I've looked at the old warppos, but that is meant for llSetPos and uses llSetPrimitiveParams PRIM_POSITION, which I can't use. I hope I have explained myself enough.
  9. Brilliant. Perfect for what I need. Sometimes you just can't find what is staring you in the face. Thanks for that.
  10. I am making a simple combat prim that is worn above the head, giving basic info like health, but now I want to add a limited radar that gives target name, distance and which compass direction it is from the avatar. I can do the radar easily with distance, but getting a compass direction for each target is a headache. This has me stumped and if anyone can provide some simple code, I'd appreciate it.
  11. I simply asked for scripting advice. I didn't ask to be called a liar, and be called a griefer and that I should be banned. Stop with the head games. The above pyscho babble you wrote is insulting to say the least, and I ignored it for a while, but you persist. Now, the script problem is solved and nothing further needs to be said, unless you need to explain yourself more (which is not needed or wanted). THE END
  12. Thanks for your constructive advice PheebyKatz. The script now works, but not as it is presented here. What I posted earlier is just one part of the project that I was working on. There will be added checks besides the check for who is aiming at me. I will also add collision checking and checking the owner of the bullet that collided, and all these things together will ensure that no one gets shot, that shouldn't. Besides, I will not be using this outside of my parcel. It is my project and something that kept me interested. All things that shoot at people can be used to grief someone. It is how we use it that determines if we are a griefer or not. And for your info, a script similar to mine was created by someone on the old forums ages ago, so this is nothing new. SL for me was always about creating things. I've even sold a few things years ago.
  13. Thanks for you valid input, Wulfie. Fionalein, the core of the script in question was copied from the old LSL archives, dated 2008 or earlier. I am not the first, nor the last to use this script.
  14. God, some of you are toxic. Never have I been the subject of so much hate and ignorance. As I said, the script only targets avatars when they are aiming at you, and yes, you have to be in mouselook to aim at someone with a weapon. This line of code: determines if you have anyone's crosshairs are on you. Did you actually test out the script ? Obviously not, as you are incapable. Some people just like to get on their high horse and sprout crap. And as I said, I will only be using this script on my own land. I invite any Administrators to look at this post, and lock/close this thread, as I don't want to be the subject of more flaming. I have been in Second Life for over 10 years with various avatars, and never been accused of griefing. I used to enjoy the input of the advanced members of this forum, but a few individuals just can't look past their noob noses.
  15. Fionalein - The script actually detects when someone is aiming at you. Look at the script more closely. It doesn't just target anyone in mouselook, as that would be a silly thing to do. Berksey - I was only after a bit of friendly advice, nothing more. I have been in SL for many years, and I like to script, but I am no expert, and I sometimes ask for help on these forums. We are not all expert scripters. Lucia Nightfire - Again, as others, you have not bothered to read the script. It will ONLY target someone that is aiming at you in mouselook. I have no intention of using this script as a griefer tool. In fact, I only plan on using this script on my own parcel. Thankyou Rolig for your suggestion. I am already experimenting with that line of advice. Rolig, you were the only one to offer any constructive advice. I will think twice in future, when asking for help here.
×
×
  • Create New...