Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Poppet's Simple Prim Counter

Poppet McGimsie
Proprietrix, WUNDERBAR
Join date: 28 Jul 2006
Posts: 197
07-18-2007 14:56
I've seen a couple of these for cash in world, and so I decided to write my own.

Basically, it's a script that allows anyone to check and see how many prims they have on a parcel of land, just by clicking on the prim containing it.

Comments and revisions invited.

--------------------------------------------------------------------------------------------------------
CODE

//put this script in a prim and decorate it nicely. then when anyone comes up and leftclicks for a prim count, they can see how many prims they have on a particular parcel of land. Very useful for landlords with tenants who can't check their prims otherwise.
//by poppet mcgimsie, 18 July 2007, open-source and free, and must remain so.

list mylist;
list myparcellist;
list details;
vector pos;
string name;
integer index;
list element;
key searchFor;


default
{
state_entry()
{

myparcellist=llGetParcelDetails(pos, details);
mylist = llGetParcelPrimOwners(pos);

}

touch_start(integer total_number)
{
searchFor = llDetectedKey(0);
name = llDetectedName(0);
index = llListFindList( mylist, [searchFor] );
if ( index != -1 )
{
llWhisper( 0, (string) searchFor + " was found in mylist at position " + (string)index );

element = llList2ListStrided(mylist, index +1, index + 1, -1);

llWhisper( 0, (string) name + " has this number of prims: " + llList2CSV(element) );
}
else
{
name = llDetectedName(0);
llWhisper( 0, (string) name + " has no prims on this parcel!" );
}


}
}
Raphory Repine
Registered User
Join date: 16 May 2007
Posts: 9
11-20-2007 03:07
Hello,

nice script, but it doesn't work for me. I tried it on several parcels I owned, and friends tried it too, that were renting houses with their own furnitures on a parcel I own. It always says:

Object whispers: Raphory Repine has no prims on this parcel!

Any hint to make it work would be greatly appreciated!

Regards

Raph
Jana Kamachi
Registered User
Join date: 19 Apr 2007
Posts: 111
11-20-2007 03:11
restart it.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-20-2007 03:28
Uhm - maybe I'm a little blind'n'stoopid.. but I guess that there are some variables missing?

myparcellist=llGetParcelDetails(pos, details);
mylist = llGetParcelPrimOwners(pos);

Neither pos nor details is defined (they're both initialized in the header, though -> list details; vector pos; - but they're given no values).

So, if pos is an empty vector, wouldn't this end up in a value like <0.0, 0.0, 0.0>? which - I assume - would be a corner of a Sim and thus, if the parcel isn't at this position, would produce the «XXX has no Prims on this parcel»?

And in llGetParcelDetails(pos, details), shouldn't details be something like

[PARCEL_DETAILS_NAME, PARCEL_DETAILS_DESC, PARCEL_DETAILS_OWNER, PARCEL_DETAILS_GROUP, PARCEL_DETAILS_AREA]?

Since myparcellist isn't used in the code, this won't produce an error or false behaviour - but the call itself is pretty useless as it wouldn't return any values at all...

Correct me if I'm wrong, please :)
Raphory Repine
Registered User
Join date: 16 May 2007
Posts: 9
11-20-2007 03:55
From: Jana Kamachi
restart it.


I already tried it, of course :) And no, It doesn't work at all... :-(
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-20-2007 04:03
ok - try this:
(untested - there might be errors - I'm at work and can't go inworld :)

CODE

//put this script in a prim and decorate it nicely. then when anyone comes up and leftclicks for a prim count, they can see how many prims they have on a particular parcel of land. Very useful for landlords with tenants who can't check their prims otherwise.
//by poppet mcgimsie, 18 July 2007, open-source and free, and must remain so.

list mylist;
list myparcellist;
list details;
vector pos;
string name;
integer index;
list element;
key searchFor;


default
{
state_entry()
{

pos = llGetPos();
details = [PARCEL_DETAILS_NAME];

myparcellist=llGetParcelDetails(pos, details);
mylist = llGetParcelPrimOwners(pos);

}

touch_start(integer total_number)
{
searchFor = llDetectedKey(0);
name = llDetectedName(0);
index = llListFindList( mylist, [searchFor] );
if ( index != -1 )
{
llWhisper( 0, (string) searchFor + " was found in mylist at position " + (string)index );

element = llList2ListStrided(mylist, index +1, index + 1, -1);

llWhisper( 0, (string) name + " has this number of prims: " + llList2CSV(element) );
}
else
{
name = llDetectedName(0);
llWhisper( 0, (string) name + " has no prims on parcel!" + (string)myparcellist );
}


}
}


The changes are only in «state_entry» and in the end of the code, where it should say the name of the parcel...

Again - it's untested, but that's what I assume should be added to the code...
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
11-20-2007 04:25
Please note that some of those commands require you to actually own the parcel or be an EM or sim owner.

If the parcel is deeded to a group you need to be an officer in the group to get the script working properly.

If you do not have the proper permissions then the script will not work properly and usually just tell you that you have no prims on the parcel.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-20-2007 05:00
Just a clarification for me... please...

It's important, that the person who places this object (where the script is in) is the SIM/Parcel-Owner, not the person who CLICKS on the object, is that right?
Shyan Graves
Registered User
Join date: 10 Feb 2007
Posts: 52
Good work!!
11-20-2007 05:15
Nice script, thanks for posting it Poppet in the first place and submitting the changes Haruki, I appreciate your work guys.

But I see one disadvantage (if I am not missing something here) in this implementation, cause the list mylist is only filled once in state_entry, on the first time the object is rezzed or the script is resetted. Cuz the state_entry event will only be fired once the default state is entered, changes that where made afterwards are not in the list. Which makes this script very useless for tenant of a mall, cuz they normally want to know how many prims are left for their business, don't they?

Wouldn't it be better to put the line "mylist = llGetParcelPrimOwners(pos);" in the touch event? So that it will be filled with the actual data?

Shyan
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-20-2007 05:27
You're absolutely right, Shyan.

I was actually more focused on the «not-working-part» of the script and didn't really look at the logic itself...

good point!
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
11-20-2007 06:00
I'm not getting it. Can't you just check this in the Objects tab in About Land? It shows me who owns prims and even highlights them for me.

I must be missing something here.
Haruki Watanabe
llSLCrash(void);
Join date: 28 Mar 2007
Posts: 434
11-20-2007 06:08
It's for others having prims on your land (like shop-owners) to see how many prims they have. Ppl, who aren't allowed to have a look at the Land-Info.. :)
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
11-20-2007 06:31
From: Haruki Watanabe
It's for others having prims on your land (like shop-owners) to see how many prims they have. Ppl, who aren't allowed to have a look at the Land-Info.. :)

Ahhh, ok. Thanks. Great idea if one rents out space.
Poppet McGimsie
Proprietrix, WUNDERBAR
Join date: 28 Jul 2006
Posts: 197
12-07-2007 11:14
thanks everyone! Sorry I was not paying attention to this thread. Thanks for the fixes, and if more are called for, keep them coming!

I did test the script myself and on an alt before posting it, and I thought it worked, but obviously it needs some tweaking!
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
12-07-2007 12:11
From: Squirrel Wood
If the parcel is deeded to a group you need to be an officer in the group to get the script working properly.
See http://jira.secondlife.com/browse/SVC-25. This reconciles a bunch of seemingly contradictory results reported in the wiki (http://www.lslwiki.net/lslwiki/wakka.php?wakka=llGetParcelPrimOwners). In short, if the script is supposed to work on group-owned land all the time, the object containing the script should be deeded to group.
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
12-10-2007 18:44
It may be ultimately that calling on llGetParcelPrimOwners is ultimately a condition of operation -- who owns the counter, compared with who owns the land or how ithe land is owned (or it may be the phase of the moon even though in theory there aren't any here... grin)

Here's my take at putting this into plain English, for discussion......

For this to work, owing to restrictions imposed by Lindenscript, one of the following conditions must be true. Otherwise, you will just receive some 0's, though you still can get the overall number of objects on the parcel.

In short, if the parcel is owned by a person, then the object calling on llGetParcelPrimOwners must be owned by that person. If the parcel is group owned, then the object calling on llGetParcelPrimOwners must either:
(a) Be deeded to the group OR
(b) The person who owns the Prim Diddler must be an officer in the group that owns the land *and* that person must have rights to either return group owned objects, return group set objects, or return non-group objects.

The full reasoning is that worthy of any Byzantine diplomat. Here it is in the words of a Linden:

"The expected behavior of this function is:
* If the object owner is the same as the parcel owner (including if the object and parcel are both group owned) get all object owners.
* If not and the parcel is group owned, then we must check group powers and return results as follows:
* * If the resident has the 'return group owned objects' power, we return a list of just the group if there are any group owned objects on the parcel.
* * If the resident has the 'return group set objects' power we return a list of all owners who have objects set to the group on the parcel
* * If the resident has the 'return non-group objects' power we return a list of all owners of objects that don't fall into the above." Kelly Linden, 26 November 2007. https://jira.secondlife.com/browse/SVC-25.
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
12-10-2007 20:50
Right, but one other complication: "Group powers can only be checked while the agent is online and in the same region (there is some slop here relating to child cameras, which can let the function work if you are nearby or were recently in the sim etc). "

So... if it's not deeded to group and owned by somebody with the right perms, it'll work except when s/he's not around, but s/he won't know--because s/he's not around. (It's kinda like the light in the refrigerator... uh... nevermind. :o )
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
12-10-2007 21:19
Yeah Qie, very good addition!

I didn't add that yet, because .. well here's what I'm testing.

A friend is an officer with full privileges in the group that my land is deeded to. I handed him a prim with Poppet's script in it, and got him to put it out. It worked, under his officer privileges, as it should based on the theory. But it continued working even when I revoked all three of his "return stuff" privileges, and even when I reduced him from officer to lowlife slug status. [1]

When he left the SIM it continued to work for some time after that (well, by which point, he'd come back because he got bored standing around somewhere else, LOL.) Now, he's just logged for the night, 10 minutes ago exactly, and it's still working. I'm going to keep on testing for a bit to see at what point it stops working, as according to the theory, it should, cause he's no longer around to check his group privileges on.

[1] I have a theory about this. Quite vague. You know when you have land deeded to a group, and sell it by mistake still at that status, and during the night all the money distribution happens? Maybe it's only during the night as some group refreshing stuff happens as well that his group privileges statuses actually get re-read by the back-end system, and kick in. Dunno.
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
12-10-2007 21:55
a) Still working 47 minutes after he logged.

b) Still working 2 1/2 hours after he logged, but calling it a night now.

c) Next morning, about 8 to 9 hours later, my friend hasn't been back on line yet, but the prim counter is still working.

The theory I'm testing, to recap, is that at some point it should stop working because:
(1) land is deeded to group;
(2) though he's an officer in the group with three of the return conditions specified below, he's not online so that his privileges can be verified.
Poppet McGimsie
Proprietrix, WUNDERBAR
Join date: 28 Jul 2006
Posts: 197
12-11-2007 08:41
Oh my, so we now have the little man in the refrigerator who turns off the light when the door is shut, and we have the elves that come and fix things during the night?


I am happy that this is challenging even for real scripters; makes me feel less stooopid about not actually defining "pos" in the script (which btw explains why people who were using it other places on the grid were being told how many prims they had on my sim, unless they actually hard-reset the script)