Difference between revisions of "How do I make a donation box?"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<noinclude>{{KBmaster}}</noinclude>
{{LSL Header}}
 
A donation box is a scripted object that Resident can right-click (CMD-click on Macintosh) and pay without receiving a service or object in return. You can make any object a donation box by adding a small script to it. To do so:  
A donation box is a scripted object that Resident can right-click (CMD-click on Macintosh) and pay without receiving a service or object in return. You can make any object a donation box by adding a small script to it. To do so:  
# Right-click the object inworld and choose '''Edit'''.  
# Right-click the object inworld and choose '''Edit'''.  
Line 7: Line 8:
# Click '''Save'''. If the compile is complete, close the script window and editing window. The '''Pay''' option should now appear in the pie menu when a Resident right-clicks on the object. Sample Donation Script:  
# Click '''Save'''. If the compile is complete, close the script window and editing window. The '''Pay''' option should now appear in the pie menu when a Resident right-clicks on the object. Sample Donation Script:  


<lsl>
<source lang="lsl2">
default {  
default
     touch_start(integer total_number) {  
{
         llSay(0, "Please right-click me and select 'Pay...' to donate.");
     touch_start(integer num_detected)
     }  
    {
   
         llRegionSayTo(llDetectedKey(0), 0, "Please right-click me and select 'Pay...' to donate.");
     money(key giver, integer amount) {  
     }
         string donor = llKey2Name(giver);
 
         llInstantMessage(giver,"Thank you for your donation, " + donor + "!");
     money(key id, integer amount)
         llInstantMessage(llGetOwner(),donor + " has donated '''L'''$" + (string)amount + " to you.");
    {
         string name = llKey2Name(id);
 
        key owner = llGetOwner();
 
         llInstantMessage(id, "Thank you for your donation, " + name + "!");
         llInstantMessage(owner, name + " has donated " + (string)amount + " L$.");
     }
     }
}</lsl>
}
</source>


Once the script is installed, you can easily change the donation box's properties to accept left-clicks as well.
Once the script is installed, you can easily change the donation box's properties to accept left-clicks as well.
Line 26: Line 34:
# At the bottom left, you'll see a dropdown list labeled '''When Left-Clicked:'''
# At the bottom left, you'll see a dropdown list labeled '''When Left-Clicked:'''
# Set the option to '''Pay''' and close the editing window.
# Set the option to '''Pay''' and close the editing window.
[Category:Content Creation]]
[[Category:Content creation]]
[[Category:Scripting]]
[[Category:Linden dollars (L$)]]
[[Category:Landowners]]


[[Category:Tips and Tricks]]
{{LSLC|Examples|How do I make a donation box?}}

Latest revision as of 15:16, 24 January 2015

A donation box is a scripted object that Resident can right-click (CMD-click on Macintosh) and pay without receiving a service or object in return. You can make any object a donation box by adding a small script to it. To do so:

  1. Right-click the object inworld and choose Edit.
  2. Click on the Content tab. (Click More if you don't see it.)
  3. Click the New Script button.
  4. Delete everything in the script. Copy and paste the text in the box below.
  5. Click Save. If the compile is complete, close the script window and editing window. The Pay option should now appear in the pie menu when a Resident right-clicks on the object. Sample Donation Script:
default
{
    touch_start(integer num_detected)
    {
        llRegionSayTo(llDetectedKey(0), 0, "Please right-click me and select 'Pay...' to donate.");
    }

    money(key id, integer amount)
    {
        string name = llKey2Name(id);

        key owner = llGetOwner();

        llInstantMessage(id, "Thank you for your donation, " + name + "!");
        llInstantMessage(owner, name + " has donated " + (string)amount + " L$.");
    }
}

Once the script is installed, you can easily change the donation box's properties to accept left-clicks as well.

  1. If you've closed the editing window, right-click the object and choose Edit again.
  2. Make sure you're on the General tab in the Editor. (Click More if you don't see it.)
  3. At the bottom left, you'll see a dropdown list labeled When Left-Clicked:
  4. Set the option to Pay and close the editing window.