So, I made this llGetParcelPrimCount HUD thingy...
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-07-2006 15:40
This is the first real script I've made myself, and I like it because it suits my purpose very well, but I don't know enough about scripting to know how stressful it may be on resources at my current settings, or who it would effect. I set it to get the prim counts on a timer so it stays updated as I'm building. Does this script (function or whatever) get this information by literally scanning the land and counting prims, or does it get it from the land info already gathered by the server (or client)? If it updates every second, is that bad, very bad, okay, or no problem at all?  Help a noob scripter out! *edit* Since there's not a "llGetParcelPrimsAvailable" is there a way to make it give you that as your feedback? (make it do the math for you...)
_____________________
You can find my products at these locations:
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-07-2006 19:04
I just made mine to get the information when I touch it. No one is building fast enought to worry about how many prims they have left every second. So you could keep on using the timer but I would turn it way down, like every few minutes and only running when you touch it on/off. And yes it does go throught the server everytime. You will notice that I just did the math to see how many prim are available: list lstParcelDetails; list lstParcelName; integer allowed; integer total; integer free; string owner; string group; string other; string temp;
default { touch_start(integer num_detected) { allowed = llGetParcelMaxPrims(llGetPos(), FALSE); total = llGetParcelPrimCount(llGetPos(), 0, FALSE); free = allowed - total; owner = (string)llGetParcelPrimCount(llGetPos(), 1, FALSE); group = (string)llGetParcelPrimCount(llGetPos(), 2, FALSE); other = (string)llGetParcelPrimCount(llGetPos(), 3, FALSE); temp = (string)llGetParcelPrimCount(llGetPos(), 5, FALSE); lstParcelDetails = [0, 1, 2, 3, 4]; lstParcelName = llGetParcelDetails(llGetPos(), lstParcelDetails); llRequestAgentData(llList2Key(lstParcelName, 2), DATA_NAME); } dataserver(key queryid, string data) { list name = (list)data; lstParcelName = llListReplaceList(lstParcelName, name, 2, 2); llOwnerSay(llList2CSV(lstParcelName) + "\nallowed = " + (string)allowed + "\ntotal = " + (string)total + "\nfree =" + (string)free + "\nowner = " + owner + "\ngroup = " + group + "\nother = " + other + "\ntemp = " + temp); llResetScript(); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-07-2006 19:08
Oh, wow, that is so much scripting you got there.  Way above my head.
_____________________
You can find my products at these locations:
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-07-2006 19:58
From: Stormy Roentgen Oh, wow, that is so much scripting you got there.  Way above my head. heehee. Don't worry, you will get there in time also. Just take my code and drop it in a prim, touch it and see what it does. And you did a great job for your first "real" script!!!!!!
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-08-2006 01:56
Jesse, why are you calling llGetPos() seven times? list lstParcelDetails = [PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC, PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP, PARCEL_DETAILS_AREA]; list lstParcelName; vector pos;
default { touch_start(integer num_detected) { pos = llGetPos(); lstParcelName = llGetParcelDetails(pos, lstParcelDetails); llRequestAgentData(llList2Key(lstParcelName, 2), DATA_NAME); } dataserver(key queryid, string data) { integer allowed = llGetParcelMaxPrims(pos, FALSE); integer total = llGetParcelPrimCount(pos, PARCEL_COUNT_TOTAL, FALSE); integer free = allowed - total; string owner = (string)llGetParcelPrimCount(pos, PARCEL_COUNT_OWNER, FALSE); string group = (string)llGetParcelPrimCount(pos, PARCEL_COUNT_GROUP, FALSE); string other = (string)llGetParcelPrimCount(pos, PARCEL_COUNT_OTHER, FALSE); string temp = (string)llGetParcelPrimCount(pos, PARCEL_COUNT_TEMP, FALSE); list name = (list)data; lstParcelName = llListReplaceList(lstParcelName, name, 2, 2); llOwnerSay(llList2CSV(lstParcelName) + "\nallowed = " + (string)allowed + "\ntotal = " + (string)total + "\nfree =" + (string)free + "\nowner = " + owner + "\ngroup = " + group + "\nother = " + other + "\ntemp = " + temp); //llResetScript(); } }
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-08-2006 06:16
From: Newgate Ludd Jesse, why are you calling llGetPos() seven times?
ah never even noticed. It was a test script I threw together in Beta to check the new functions. I'll optimize it later and repost. Plus I was checking to see if you were paying attention 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
12-08-2006 10:27
A little bit more efficient and took out the data server query: string allowed; string total; string free; string owner; string group; string other; string temp; vector pos; integer category; string count;
prim(){ count = (string)llGetParcelPrimCount(pos, category, FALSE); category++; }
default { touch_start(integer num_detected) { category = 0; pos = llGetPos(); allowed = (string)llGetParcelMaxPrims(pos, FALSE); prim(); total = count; free = (string)((integer)allowed - (integer)total); prim(); owner = count; prim(); group = count; prim(); other = count; category = 5; prim(); temp = count; llOwnerSay("allowed = " + allowed + "\ntotal = " + total + "\nfree =" + free + "\nowner = " + owner + "\ngroup = " + group + "\nother = " + other + "\ntemp = " + temp); } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-08-2006 12:43
Reading over your codes are so helpful. I made alot of changes. Oh, and I happen to be someone who needs to the second updates... when I am in the process of building. I work on my own lot and I'm always pulling out additional builds to get pieces of this and that to use on something new I'm making. My stuff is pretty heavy on prims compared to my parcel size. I am going to make this turn on and off by touch as soon as I get states figured out. Still working on it. I made this so that the text turns red if my available prims is <150. I would like to change that to "if ((integer)available < 10% of (integer)allowed)" but I know I can't stick "10% of" in there.  Is there a way to incorporate percentages into a script?
_____________________
You can find my products at these locations:
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-08-2006 12:48
if((integer)available < ((float)0.10 x (integer)allowed) I know that's not valid, but you see what I'm trying to do. How do I make it do math!? hehe *edit* omg omg omg, I figured it out.  if((integer)available < ((float)0.10* (integer)allowed))
_____________________
You can find my products at these locations:
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-08-2006 13:34
From: Stormy Roentgen if((integer)available < ((float)0.10 x (integer)allowed) I know that's not valid, but you see what I'm trying to do. How do I make it do math!? hehe *edit* omg omg omg, I figured it out.  if((integer)available < ((float)0.10* (integer)allowed)) you dont need all the cast's. if(available < (0.1 * allowed) ) I'm getting the feeling that you dont really understand what it is you are doing, just copying / paraphrasing?
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-08-2006 14:04
From: Newgate Ludd you dont need all the cast's.
if(available < (0.1 * allowed) )
I'm getting the feeling that you dont really understand what it is you are doing, just copying / paraphrasing? I have them all there because when I get errors or the script doesn't work as I intend it to, I keep readjusting until it does what it's suppose to, and at some point the script worked after I added some casts. Yes, I do understand what the casts do. No I did not know they weren't necessary everytime, and I did not know they were called casts. I told you I am learning.  I've taken scripting 101, but other than that I have no scripting or programming experience. And your "if(available < (0.1 * allowed) )" gives a type mismatch error.
_____________________
You can find my products at these locations:
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-08-2006 15:07
From: Stormy Roentgen I have them all there because when I get errors or the script doesn't work as I intend it to, I keep readjusting until it does what it's suppose to, and at some point the script worked after I added some casts. Yes, I do understand what the casts do. No I did not know they weren't necessary everytime, and I did not know they were called casts. I told you I am learning.  I've taken scripting 101, but other than that I have no scripting or programming experience. Firstly an apology, you appear to have taken offence with my wording. It was not intended as aggressive or offensive. I choose my words poorly. Casting is the term used when you forceably convert one data type to another and is used extensively in LSL as in string str = (string)llGetPos(); when using constants its usually unnecessary to cast (as in (float)0.1 ) as the data type is inherent. From: Stormy Roentgen And your "if(available < (0.1 * allowed) )" gives a type mismatch error. It will be dependant upon the data types you are using, In my script allowed is an integer whereas I think in your script allowed is a string in which case the cast to integer will be required.
|
|
Stormy Roentgen
Prim Putter Togetherer
Join date: 25 May 2004
Posts: 342
|
12-08-2006 15:17
Ahhh I see, and no I wasn't offended, though I was a little snippy because someone in another thread kinda ticked me off just before.  So I don't need to tell the script that the float is a float, but do need to tell it to convert my strings to integers. Gotcha. And I did think there was an awful lot of those in there. My first script was so much in one line of code. I'm working on learning how to shorten it to be more legible.
_____________________
You can find my products at these locations:
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-08-2006 15:27
From: Stormy Roentgen Ahhh I see, and no I wasn't offended, though I was a little snippy because someone in another thread kinda ticked me off just before.  So I don't need to tell the script that the float is a float, but do need to tell it to convert my strings to integers. Gotcha. And I did think there was an awful lot of those in there. My first script was so much in one line of code. I'm working on learning how to shorten it to be more legible. Well legibility is always a good aim. And use comments as much as you want. Keep things as simple and straight forward as you can. Who cares if you use 3 lines to do something someone else would do in one? If you're that tight for space you probably need to revist the script anyway!
|