Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Question about llSetPayPrice

Roburt Musketeer
Registered User
Join date: 31 Oct 2005
Posts: 17
01-30-2006 19:14
I doubt there is any way around this minor problem, but I'll ask anyway. :)

Here is the situation. I'm scripting a vendor for a friend. I'm trying to design it so that it is very easy to add more buttons and options to it. Thus far I have been able to code it in such a way that it doesn't matter which prim is the root prim. (Those my friend can unlink it, add another button, and relink it without worrying about which prim she made the root prim)

Now, this vendor has a single "Buy" button. I want to set that button to a single pre-selected price. Which in theory should be no problem with llSetPayPrice.

But in attempting to do so I discovered that llSetPayPrice ONLY seems to work if it's set in the root prim. You're only able to "Pay" the prim with the "money" event handler.. But the pay option apparently only listens to llSetPayPrice in the root.

Does anyone know a way around this? Off the top of my head I suppose I could add some code to check which prim is the root prim, and send a copy of a script with just llSetPayPrice in it to it. But that sounds awfully klunky and inefficient. Everytime the object is relinked and another prim becomes the root prim the object would end up with ANOTHER redundant copy of that script in another prim.

Does anyone have a more elegant solution to offer?
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-31-2006 13:31
Yes, have the script, when the object is linked, if it isn't the root prim, have it break it self off from the object, and relink it self as the root.

CODE

relink()
{
if(llGetLinkNumber() > 1)
{
if(llGetPermissions() & PERMISSION_CHANGE_LINKS)
{
key b = llGetLinkKey(LINK_ROOT);
llBreakLink(LINK_THIS);//not sure if this will work with LINK_THIS
llCreateLink(b,TRUE);
}
else
llRequestPermissions(llGetOwner(), perms);
}
}

integer perms;

default
{
state_entry()
{
perms = PERMISSION_CHANGE_LINKS | PERMISSION_DEBIT_MONEY;
llRequestPermissions(llGetOwner(), perms);
}
changed(integer a)
{
if(a & CHANGED_LINK)
{
relink();
}
}
run_time_permissions(integer perm)
{
relink();
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey