Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

discussion: Open source Wishing Well script

Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-04-2007 13:32
I am providing the wishing well script that I use in my shop as an open source script. I do hope that someone is able to put it to good use.

This script requires a base prim, and at least one child prim. The child prim is used for hover tet, and may be invisible. The Child prim requires one simple script. The more advanced script will follow the child prim's script.

CHILD SCRIPT
************
CODE

default
{
link_message( integer iLinkNum, integer iNum, string sMSG, key kID )
{
if ( iNum == 1 ) llSetText( sMSG, <1,1,1>, 1.0 );
}
}


*************************************
The following script goes into your root prim.
*************************************
CODE

// Wishing Well script
// Version 0.20
//
// By: Jim Guyot
//
// License:
// Free to use, modify or transfer.
// Do not sell this script by itself, or as a package with other scripts.
// If this script is used as part of a wishing well, or similar structure,
// it may be included as long as it retains full copy/mod/transfer permissions.
// Failure to abide by these rules will result in termination of license,
// and possible legal proceedings.
//
// Documentation for this script is provided at the end of the script.
//
// ***********************************************************************************************
//
// [Section 1]
// CONTRIBUTORS
//
// ***********************************************************************************************
//
// [Section 2]
// VARIABLES

// [Section 2.1]
// GLOBAL VARIABLES
list lWishList = [];
integer iHandle;

// ***********************************************************************************************
//
// [Section 3]
// FUNCTIONS

// ***********************************************************************************************
//
// [Section 4]
// STATES

// [Section 4.1]
// DEFAULT
default
{
// [Section 4.1.1]
// STATE_ENTRY EVENT HANDLER
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_DEBIT );
llMessageLinked( LINK_SET, 1, "Welcome to the Wishing Well.", NULL_KEY );
llListen( 123, "", llGetOwner(), "list" );
}
// [Section 4.1.2]
// ON_REZ EVENT HANDLER
on_rez( integer iNum )
{
llResetScript();
}
// [Section 4.1.3]
// RUN_TIME_PERMISSIONS EVENT HANDLER
run_time_permissions( integer iPerms )
{
if ( !( iPerms & PERMISSION_DEBIT ) ) llResetScript();
}
// [Section 4.1.4]
// MONEY EVENT HANDLER
money( key kGiver, integer iAmount )
{
llMessageLinked( LINK_SET, 1, "Thank you. In order to make a wish,\ntype '/777' and then your wish.", NULL_KEY );
iHandle = llListen( 777, "", kGiver, "" );
}
// [Section 4.1.5]
// LISTEN EVENT HANDLER
listen( integer iChannel, string sName, key kID, string sMSG )
{
if ( iChannel == 777 )
{
string sTempString = (string) kID + "||" + sMSG;
lWishList += [ sTempString ];
llMessageLinked( LINK_SET, 1, "Welcome to the Wishing Well.", NULL_KEY );
llListenRemove( iHandle );
}
if ( ( iChannel == 123 ) && ( kID == llGetOwner() ) )
{
integer i;
for ( i = 0; i < llGetListLength( lWishList ); i++ )
{
list lTempList = llParseString2List( llList2String( lWishList, i ), [ "||" ], [] );
string sTempString = llKey2Name( llList2String( lTempList, 0 ) );
sTempString = sTempString + " wished for " + llList2String( lTempList, 1 );
llOwnerSay( sTempString );
}
}
}
// [Section 4.1.6]
// TOUCH_START EVENT HANDLER ( ALL TOUCHES )
touch_start( integer iNum )
{
llSay( 0, "Right-click and select 'Pay' to drop some coins in the wishing well." );
}
}

// ***********************************************************************************************
//
// [Section 5]
// DOCUMENTATION

// Section 1
//
// This section is used for contributors and script modifiers. Please place your
// Second Life name here, in addition to any modifications you have performed on this
// script.
// I cannot guarantee that future modifications will work as desired. All relevant
// documentation for portions that I, personally, have written are included in this
// documentation. If you have any questions, please feel free to IM me. I cannot guarantee
// that I will be able help with another scripter's modifications.

// Section 2
//
// This section lists variables used by this script.
//
// Section 2.1
//
// Global Variables are variables that can be used by all functions in this script.
//
// lWishList This list holds all wishes currently available to the owner of the well.
// iHandle This is the integer value of the listen command. Used after dropping coins in the well.
//
// Section 2.2
//
// User-Defined Constants are variables that generally should not be changed during
// the course of normal script functionality.

// Section 3
//
// Functions used throughout this script are placed here. Encapsulating frequently used
// functions should be done on a normal basis.

// Section 4
//
// This section is reserved for states.
//
// Section 4.1
//
// Default state provides all access in this script. There are no state changes currently implemented.
//
// Section 4.1.1
// state_entry() event handler
// This is the initial set up state. It gets required permissions, sets hover text and sets an owner listen event.
//
// Section 4.1.2
// on_rez( integer iNum ) event handler
// If this script's containing prim is rezzed outside of standard means, reset the script.
//
// Section 4.1.3
// run_time_permissions( integer iPerms ) event handler
// If debit permissions are not granted, reset the script.This functionality is not currently in use.
// Future versions of the wishing well script will utilize this functionality.
//
// Section 4.1.4
// money( key kGiver, integer iAmount ) event handler
// If money is given using the 'Pay' feature, this script sets up the allow wishes routines.
//
// Section 4.1.5
// listen( integer iChannel, string sName, key kID, string sMSG )
// The listen event handler has two functions:
// 1) After payment, a listen event is called for the payee. It is removed after making the wish.
// After the wish is made on channel 777, the payee's key is stored, along with their wish.
// 2) Allows the owner of the well to type /123 list, and receive a detailed list of payee's and wishes.
// Section 4.1.6
// touch_start( integer iNum ) event handler
// This event handler serves to let people know what to do in order to make a wish.
// More functionality can be added at a later date. There are currently no plans for future modifications of this section.

// Section 5
//
// The documentation for this script is included here. If you have any questions about
// how this script works, please check here first before IM'ing me. Also, if you would
// like a notecard with my system of numbering and naming in order to keep this script
// consistent with myself and others who follow this methodology, please send me an IM
// and I will get it to you.
//
// Good luck,
// Jim Guyot
// Jim Guyot Custom Design - Jade's Jazz Mall, Haeoreum
[/code[

**************************
If you have any questions, comments or suggestions, please feel free to send me an IM.
Enjoy!!
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
06-04-2007 22:15
/15/8b/188614/1.html
_____________________
i've got nothing. ;)
Justin Slade
Registered User
Join date: 6 Feb 2007
Posts: 132
Script
06-06-2007 17:14
I don't see many thanking you for this..So let me be the first

THANKS
Alyona Su
Registered User
Join date: 18 Aug 2006
Posts: 5
06-11-2007 11:56
Just found this - can't wait to try it out.
If it does what I think it does - THANK YOU THANK YOU THANK YOU! :)
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-11-2007 13:02
It's basically a glorified tip jar. It does, however, allow people putting tips in to make a wish. Whether the owner of the well grants the wish or not is entirely up to them. Hope you all have fun, and if anyone wants something simple done script-wise, send me an IM either here or in SL.

Also, if you want to see the well in action, you can visit my store. It is located at Jade's Jazz Mall in Haeoreum. IM me if you need a landmark.
madddyyy Schnook
SLGuides Virtual Worlds
Join date: 2 Jan 2006
Posts: 207
06-12-2007 02:06
great thanx.