Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Yet another notecard giver - on steroids...

Virgix Bing
Registered User
Join date: 26 Apr 2007
Posts: 1
01-24-2008 09:11
Yet another notecard giver... but this has has a lot of features - see sorce code below - and not only can give a notecard, but also a texture and a LM - and any combination of the three!

You can get the code and the real thing also in-world at the address http://slurl.com/secondlife/Nimnam/118/165/114 - look for a box "VIRGIX AUTOMATIC NOTECARD GIVER".

CODE

//********** VIRGIX NOTECARD, TEXTURE 6 LANDMARK AUTOMATIC GIVER *******************
// By Virgix Bing - free to use!
//Yet another script who gives everyone a notecard, a texture and a LM... or any combination of the three!

//So, what is new? Basically, three things:

// 1) Key of the avies...
// this can be really useful to send automatic messages to your visitors;
// 2) Auto-reset:
// never go out-of-memory!
// 3) Mail reports:
// you get automatic mail reports, see example below.
// 4) Fully notecard configurable:
// set up once and forget it!
// 5) you can choose the number of the items to give:
// if you want to give three things, or only one, or a combination of the three...
// simply put only a textute, name it as you like, and the script will give out only a texture!
// 6) the usual help... simply say "#help" in chat (without quotes).
//

//Mail report example:

// Subject: Visitor list - update!
// From: Virgix Notecard giver <dbcfd3dc-878e-c9aa-88c0-76449215d8ef@lsl.secondlife.com> to virgix

//Object-Name: Virgix Notecard giver
//Region: Epilais (255232, 263424)
//Local-Position: (82, 180, 265)

//Visitor List:
//Alex Astino , 96a51525-c63b-4471-8446-720d762ff742
//Man Oxe , 4b352511-85bd-4320-8a26-d968a20bad86
//Gillo Rax , e6252525-e702-46fc-8c8f-6d84fb09986e
//Total = 3
//* End of listing *



//No need to configure from here: the script reads
//the configuration from a notecard called "configuration"
//see below for details:

//# This is the configuration file
//# The name of the notecard you will give
//notecard=MyNotecard
//# Range form the object in which it will give the notecard.
//range=50
//# Email to send listings
//email_address=virgix@virgilio.org
//# Rate in seconds of scan for people to give notecard too. Should increase with range.
//# NOTE: the lower it is the more laggy it is so think before you put it on 0.1.
//rate=5
//# Name of the object
//name=Virgix Notecard giver
//#hovertext is the text over the object: if set to "N" (without quotes) no text will showed
//hovertext=Automatic notecard giver
//# end of the configuration file


string notecard_name = "configuration"; // name of notecard goes here

// internals
integer DEBUG = FALSE; // TRUE;
integer line;
key queryhandle; // to separate Dataserver requests
key notecarduuid;
list given_to;
list given_to_name;
integer max_length = 20; // Maximum length the list can reach before reseting
integer current_number = 0;


// Config data loaded from notecard, with some sane defaults
string notecard = "MyNotecard"; // The notecard to give (must be in objects inventory)
string email_address = "unknown@noserver.urk";
float range = 50; // Range form the object in which it will give the notecard.
float rate = 5; // Rate in seconds of scan for people to give notecard too. Should increase with range.
// NOTE: the lower it is the more laggy it is so think before you put it on 0.1.
string name = "Notecard giver";
string hovertext = "Notecard giver beta";

// is name on admitted list?
integer check_given_list (string name)
{
if ( llListFindList(given_to_name, [name]) >= 0 )
{
return TRUE;
} else
{
return FALSE;
}
}
Reset_List()
{
string body = "Visitor List:";
integer len = llGetListLength( given_to_name );
integer i;
for( i = 0; i < len; i++ )
{
body = body + "\n" + (llList2String(given_to_name, i) + " , " + llList2String(given_to, i));
}
body = body + "\n" + ("Total = " + (string)len );
body = body + "\n" + ("* End of listing *");

llEmail( email_address, "Visitor list - update!" ,body);
given_to = [];
given_to_name = [];
llOwnerSay("Reset done!");
}
init()
{
queryhandle = llGetNotecardLine(notecard_name, line = 0);// request line
notecarduuid = llGetInventoryKey(notecard_name);
}
default
{
state_entry()
{
llSetText( "INITIALIZING:\n please wait...", <1.0,0.0,0.0>, 1.0 );
init();
}

dataserver(key query_id, string data)
{
if (query_id == queryhandle)
{
if (data != EOF)
{ // not at the end of the notecard
// yay! Parsing time

// pesky whitespace
data = llStringTrim(data, STRING_TRIM_HEAD);

// is it a comment?
if (llGetSubString (data, 0, 0) != "#")
{
integer s = llSubStringIndex(data, "=");
if(~s)//does it have an "=" in it?
{
string token = llToLower(llStringTrim(llDeleteSubString(data, s, -1), STRING_TRIM));
data = llStringTrim(llDeleteSubString(data, 0, s), STRING_TRIM);

//Insert your token parsers here.
if (token == "email_address")
email_address = data;
else if (token == "rate")
rate = (integer)data;
else if (token == "range")
range = (integer)data;
else if (token == "name")
name = (string)data;
else if (token == "hovertext")
hovertext = (string)data;
else if (token == "notecard")
notecard = (string)data;

}
}

queryhandle = llGetNotecardLine(notecard_name, ++line);
if(DEBUG) llOwnerSay("Notecard Data: " + data);
}
else
{
if(DEBUG) llOwnerSay("Done Reading Notecard");

llOwnerSay("-- Configuration as read from " + notecard_name + "--");
llOwnerSay("Email set to " + (string)email_address);
llOwnerSay("rate set to: " + (string)rate);
llOwnerSay("name of the object set to: " + (string)name);
llOwnerSay("range of object set to: " + (string)range);
llOwnerSay("Text over object set to: " + (string)hovertext);
llOwnerSay("Name of notecard set to: " + (string)notecard);
llOwnerSay("-- End of configuration of " + (string)name + "--");
llOwnerSay("** to change configuration edit the object and change + " + notecard_name + "**");

if (hovertext == "N")
{
llSetText( "", <0,0,0>, 0.0 );
}
else
{
llSetText( hovertext, <0.0,1.0,1.0>, 1.0 );
}


llSetObjectName(name);
llSetObjectDesc("Supplied by Virgix Bing");
llSensorRepeat("", "", AGENT , range, PI,rate);
llListen(0, "", llGetOwner(), "");
llSay(0, "Activated.");

}
}
}

sensor(integer num_detected)
{
integer i;
integer group_members = 0;
for (i = 0; i != num_detected; i++)
{
//annoto i visitatori
if( llDetectedKey( i ) != llGetOwner() )
{
string detected_name = llDetectedName( i );

if( check_given_list( detected_name ) == FALSE )
{
given_to_name += detected_name;
given_to += (string)llDetectedKey( i );
//check if list is too big
if (llGetListLength(given_to) > max_length) Reset_List();
//Give al...
if (llGetInventoryType(notecard) != INVENTORY_NONE ) llGiveInventory(llDetectedKey(i),notecard);
if (llGetInventoryType(llGetInventoryName(INVENTORY_TEXTURE, 0)) != INVENTORY_NONE ) llGiveInventory(llDetectedKey(i),llGetInventoryName(INVENTORY_TEXTURE, 0));
if (llGetInventoryType(llGetInventoryName(INVENTORY_LANDMARK, 0)) != INVENTORY_NONE ) llGiveInventory(llDetectedKey(i),llGetInventoryName(INVENTORY_LANDMARK, 0));
llSay(0, "You welcome, " + detected_name);
if(DEBUG) llOwnerSay("Materials given to: " + detected_name);
}
}
}
}

// since it uses notecards, change values when inventory changes
changed(integer change)
{
// We want to reload channel notecard if it changed
if (change & CHANGED_INVENTORY)
if(notecarduuid != llGetInventoryKey(notecard_name))
init();
}

listen(integer channel, string name, key id, string message)
{
if(message == "#help")
{
llOwnerSay("Here are a list of commands:");
llOwnerSay("#help - this message");
llOwnerSay("#reset - reset list");
llOwnerSay("#list - says the names of the avatars");
}

else if(message == "#reset")
{

Reset_List();

}
else
if( message == "#list" )
{
llOwnerSay("Visitor List:" );
integer len = llGetListLength( given_to_name );
integer i;
for( i = 0; i < len; i++ )
{
llOwnerSay(llList2String(given_to_name, i) + " , " + llList2String(given_to, i));
}
llOwnerSay("Total = " + (string)len );
llOwnerSay("* End of listing *");
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
01-25-2008 21:09
:-)
_____________________
i've got nothing. ;)
AnCuDubh Docherty
Registered User
Join date: 7 May 2007
Posts: 9
Ty
02-26-2008 06:36
:) TY Virgix
Gau Hax
Registered User
Join date: 4 May 2008
Posts: 9
Danke
09-20-2008 22:21
Hallo Virgix Bing,

auf die gefahr hin das du kein wort verstehst.
Danke für dein tolles script.

Ich konnte dadurch gut mit der NC auslesen lernen
Vielen Dank Gau


translate by " http://de.babelfish.yahoo.com "
at the risk which you do not understand a word. Thanks for your mad script.

I could learn to select thereby well with the numerical control
Thank you
Gau