Lindens in a box?
|
Inez Angelus
Elephant Rider
Join date: 11 Nov 2004
Posts: 129
|
01-12-2005 12:13
Some friends are getting married this weekend and I'd like to give them a nice little sum of $L as a starting-out wedding present. Is there any way to script an object so that when its touched it will give an amount I previously specify? I'd like to put it in a nice gift-box type object. Of course, I only want it to give the amount once  Thank you oh benevolent scripters that make this crazy SL world go 'round! -Inez
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
01-12-2005 13:08
This is quick and dirty and un-tested in-world, but should theoretically work. If the named recipient touches the object containing this script, it will pay them the amount specified, then self-delete.  integer AMOUNT = 0 ; // Place the amount you want to give here!
string RECIPIENT = "" ; // Place the name of the intended recipient here!
key owner ;
default { state_entry() { owner = llGetOwner() ; llRequestPermissions( owner, PERMISSION_DEBIT ) ; } touch_start( integer num ) { if( llDetectedName( 0 ) == RECIPIENT ) { llGiveMoney( llDetectedKey( 0 ), AMOUNT ) ; llDie() ; } } } I imagine this script will fail if they take actually ownership of the object, or at the least they'll end up paying themselves. 
_____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
|
Torley Linden
Enlightenment!
Join date: 15 Sep 2004
Posts: 16,530
|
01-12-2005 13:36
Hmmmmmm a curious idea. Pituca Chang has some realllly cute gift boxes and bags that can only be opened by a designated recipient, but I think they can only give an object, not L$. I wonder though! Pituca? 
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
01-12-2005 13:50
it looked like your code was going to compare some ones name to thier key. Witch would fail. Unless llKey2Name was called. So I added that and a little error code. I haven't loged into sl yet so I can't test this. //settings integer AMOUNT = 0 ; // Place the amount you want to give here! string RECIPIENT = "" ; // Place the name of the intended recipient here! string message = "happy birthday!" // this message will be displayed when money is given //dynamic do not edit values manually, they will be lost key giverID = NULL_KEY;
key owner ;
default { state_entry() { giverID = llGetOwner() ; llInstantMessage ( giverID, "would like to give $" + (string)AMOUNT + "to /"" + RECIPIENT +"/" when they touch this object." ); llRequestPermissions( owner, PERMISSION_DEBIT ) ; } touch_start( integer num ) { if ( llGetPermissions() & PERMISSION_DEBIT ) == PERMISSION_DEBIT) ) { key touchID = llDetectedName( 0 ); if( llKey2Name ( touchID ) == RECIPIENT ) { llGiveMoney( llDetectedKey( 0 ), AMOUNT ); llSay ( 0, message ); llSay ( 0, llKey2Name ( giverID ) + " has given $" + (string) AMOUNT + " to " + RECIPIENT + "." ); AMOUNT = 0; llDie() ; } else if ( touchID == giverID ) { llInstantMessage( touchID, " "+ (string) AMOUNT + " to '" + RECIPIENT + "'." ); } else { llInstantMessage ( touchID, "I'm sorry this object is for /"" + RECIPIENT + "/" not /"" + llKey2Name ( touchID ) + "/"." ) ; llInstantMessage ( touchID, "if you think this is wrong contact the creator." ) ; } } else { llInstantMessage ( llGetOwner() , "woops permistion not set"); } }
}
|
Inez Angelus
Elephant Rider
Join date: 11 Nov 2004
Posts: 129
|
01-12-2005 13:57
You guys are the frikkin' coolest. Rawk.  -Inez (P.S. I will try tonight with a friend and a sequence of 1 $L until we figure out if it works or if I'm just silly. Or both.)
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
01-12-2005 17:55
Note that llDie won't work if the object is attached. If your friend attaches it and keeps clicking, they will be able to debit your account indefinately. Also, Kurt, you were incorrect in your statement about Cross's posted script, it compared the value in RECIPIANT (a name) to the value in llDetectedName(). Though the added permissions check in the touch_start event was a nice touch  . Here's my version: // Constants / Settings: string MESSAGE = "Happy Birthday from Inez!"; // Message for recipiant here. string RECIPIENT = "John Doe"; // Recipiant name here. integer AMOUNT = 0; // Amount to give. // Global variables: key giver;
default { state_entry() { giver = llGetOwner(); llInstantMessage(giver, "Please accept permission request before transferring this object."); llRequestPermissions(giver, PERMISSION_DEBIT); } run_time_permissions(integer perms) { if (perms & PERMISSION_DEBIT) { llInstantMessage(giver, "This object will give " + (string) AMOUNT + " to " + RECIPIENT + " when it is touched by " + RECIPIENT llInstantMessage(giver, "This object is ready to be transferred."); } } touch_start(integer touchers) { if (llDetectedName(0) == RECIPIENT) { if (llGetPermissions() & PERMISSION_DEBIT) { key recieverKey = llDetectedKey(0); llInstantMessage(recieverKey, MESSAGE); llInstantMessage(giver, (string) AMOUNT + " has been given to " + RECIPIENT); AMOUNT = 0; llRemoveInventory(llGetScriptName()); llDie(); state dead; // Just in case the above failed to kill script. } } } }
state dead { state_entry() { llRemoveInventory(llGetScriptName()); llDie(); llSetTimerEvent(30); } timer() { llRemoveInventory(llGetScriptName()); llDie(); } }
|
Cross Lament
Loose-brained Vixen
Join date: 20 Mar 2004
Posts: 1,115
|
01-12-2005 23:30
From: Christopher Omega Note that llDie won't work if the object is attached. If your friend attaches it and keeps clicking, they will be able to debit your account indefinately. Oooh, good point, Chris! Hehe, this is why I'm a 'hack' and not a 'real scripter'.  I was assuming that the box was remaining in Inez ownership, which looking back, is kinda silly of me. 
_____________________
- Making everyone's day just a little more surreal -
Teeple Linden: "OK, where did the tentacled thing go while I was playing with my face?"
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
01-13-2005 05:49
Have you guys tested this? I don't think it will work, because a script can't have someone else's debit permissions. As soon as your gift-box becomes owned by someone else, it loses your debit permissions. Of course, if you rez the gift-box (and you remain the owner), I think all of the posted scripts will work for you. Cheers 
_____________________
-- ~If you lived here, you would be home by now~
|
Adam Zaius
Deus
Join date: 9 Jan 2004
Posts: 1,483
|
01-13-2005 05:57
Ditto on what Francis said. You will need to somehow communicate to an object you own and you have given debit permissions on to transfer cash.
-Adam
|
blaze Spinnaker
1/2 Serious
Join date: 12 Aug 2004
Posts: 5,898
|
01-13-2005 06:01
Yeah, probably a better approach will be something that sends an inworld email to another object and tells it to pay the user.
I'd probably hardcode the keys of the avatars to get the money, but that's simply the paranoid programmer in me.
If you want to give it to the first person that touches the object, than you might want to md5 against a secret, but then you have to assume nobody can hack scripts.
Of course, all transfers are recorded so if someone does hack it they risk getting banned.
_____________________
Taken from The last paragraph on pg. 16 of Cory Ondrejka's paper " Changing Realities: User Creation, Communication, and Innovation in Digital Worlds : " User-created content takes the idea of leveraging player opinions a step further by allowing them to effectively prototype new ideas and features. Developers can then measure which new concepts most improve the products and incorporate them into the game in future patches."
|
Inez Angelus
Elephant Rider
Join date: 11 Nov 2004
Posts: 129
|
01-13-2005 06:21
Or...... I could just quit trying to be so damn cutsie and give him the money outright  No, seriously, I really appreciate everyone's thoughts and efforts on this. If all else fails, I'm really learning a lot about scripting by reading through the code and then the comments about it. Maybe someday I can get to the level where I can make something DO something and not just have it sit around and look purty...and not have to rely on greater minds than my own to make something remotely functional.... thanks again guys!
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
01-13-2005 07:20
You can always im me in game if you have any questions. I do tutoring too ^.^
|
Inez Angelus
Elephant Rider
Join date: 11 Nov 2004
Posts: 129
|
01-13-2005 07:30
From: Kurt Zidane You can always im me in game if you have any questions. I do tutoring too ^.^ Thanks Kurt! I just might take you up on that offer. I taught myself HTML/CSS but I understand that's the equivilent of scripting baby steps. I can fudge around existing scripts but writing from scratch always gets me befuddled. I'm willing to pay an hourly wage for lessons. Are you available on weekends? Aw never mind, I'll IM ya inworld. 
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
01-13-2005 08:55
I'm sorry, I had to:
Stop to sell Lindens in a box!
_____________________
</sarcasm>
|
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
|
01-13-2005 09:34
It may be worth mentioning that the attachment hack (and any re-entrancy issues -- don't know those details about scripting yet) can be avoided with a spin-lock/"mutex"/what-have-you. Eg. integer moneyGiven = FALSE;
...
if (they touched it && !moneyGiven) { moneyGiven = TRUE; // this must precede the giving of the money llGiveMoney( ... ); ... }
Something like that ensures that in the worst case scenario, they will fail to receive the money (and they can IM you about the problem).
|
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
|
01-13-2005 10:09
true, but if the script set the value to 0. Witch it dose, and it's the only thing that changes the value. Witch it is. Then they would have to get the script to restart. At witch point the script restarts, loosing it's permission. If they copy the object. The copy has the same issue.
Personally the idea of giving any one a script that has a permission of mine, like money give me the hebby geebys. I'd always go the e-mail route.
|
Francis Chung
This sentence no verb.
Join date: 22 Sep 2003
Posts: 918
|
01-14-2005 09:28
From: gene Poole It may be worth mentioning that the attachment hack (and any re-entrancy issues -- don't know those details about scripting yet) can be avoided with a spin-lock/"mutex"/what-have-you.
Gene - it's a bit more complex than that. Anone can reset a script they own, thus, clearing your flag / breaking the spinlock.
_____________________
-- ~If you lived here, you would be home by now~
|