Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Floating text over box.

Vissilith Nephilim
Registered User
Join date: 17 Jan 2006
Posts: 9
07-27-2006 18:24
Would anyone mind explaining how to create a clickable box with floating text above it that opens a notecard? I've tried looking over other modifible boxes like the one I explained and copying it, but to no avail.
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
07-27-2006 18:37
From: Vissilith Nephilim
Would anyone mind explaining how to create a clickable box with floating text above it that opens a notecard?


The two functions you need are llSetText() and llGiveInventory().
_____________________
Prim Composer for 3dsMax
-- complete offline builder for prims and sculpties in 3ds Max
http://liferain.com/downloads/primcomposer/

Hierarchical Prim Archive (HPA)
-- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools.
https://liferain.com/projects/hpa
Vissilith Nephilim
Registered User
Join date: 17 Jan 2006
Posts: 9
07-27-2006 19:06
Thanks, but could someone elaborate the scripting technique for this? I do not really know how to script.
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
07-27-2006 19:20
Here is some code to serve a notecard to someone who touches your item and sends their names to your email address once in a while. I also sets some text above your item.

You will need to change your hover text in the state entry method and hopefully you will change the email addrress in the timer () code at the end, otherwise I will get emails about your customers!

I wish I could remember where I got this code. I probably cobbled it together from several sources. If the author (s) recognize this code, please claim your authorship!
CODE

// Owner specific details
string strReportEmail = "eddie.vanda@gmail.com"; // SET TO YOUR EMAIL ADDRESS
integer iReportFrequency = 7200; // SET TO HOW OFTEN YOU WANT TO GET A REPORT
// One week = 604800 seconds
// One day = 86400 seconds
// 6 hours = 14400 secons
// 3 hours = 7200 secons

// Freebie info
string strFolderName;
list lstContents;

// Reporting information
list lstHistory;
integer HISTORY_REC_LEN = 2;




updateHistoryList(string strToucherName) // Runs each time someone touches, and adds the toucher to the list
{
list lstName = [strToucherName];
// Search to see if the toucher's name is already in the list
integer iListPos = llListFindList(lstHistory, lstName);

if (iListPos == -1) // Avatar is not in list, add them, with a touch count of 0
{
list lstNewEntry = [strToucherName, 0];
iListPos = 0;
lstHistory = llListInsertList(lstHistory, lstNewEntry, iListPos);
}

// get the number of times the Av has touched, and add 1
integer iNewFreebieCount = llList2Integer(lstHistory, iListPos + 1);
iNewFreebieCount = iNewFreebieCount + 1;

// replace the entry for the toucher in the list with the new details
list lstNewEntry = [strToucherName, iNewFreebieCount];
lstHistory = llListInsertList(llDeleteSubList(lstHistory, iListPos, iListPos+ HISTORY_REC_LEN - 1), lstNewEntry, iListPos);
}




string printHistoryList() // Compiles a string for the history list
{
integer pos;
integer iLength = llGetListLength(lstHistory);
string strResult;
if ( iLength == 0 ) // There are no entires in the history list
{
strResult = "Nothing to report.";
}
else
{
// puts list entries into a single string in the format
// <Name1>, <No. Times Touched1>; <NameX>, <No. Times TouchedX>;
for(pos = 0; pos < iLength; pos += HISTORY_REC_LEN)
{
string strHistoryAvatarName = llList2String(lstHistory, pos);
string strFreebieCount = llList2String(lstHistory, pos + 1);
strResult = strResult + strHistoryAvatarName + ", " + strFreebieCount + ";\n ";
}
}

return strResult;
}







default
{
state_entry()
{
llSetText("The Classic \nTouch me for a notecard\n buy Me for $120", <1,1,1>,1);
llSetTimerEvent( iReportFrequency ); //reset report timer

}


touch_start(integer total_number)
{
// Find out who clicked, and give them a note card
key giver;
giver = llDetectedKey(0);
if (giver != NULL_KEY)
{
string name = llDetectedName(0);

llGiveInventory(giver, llGetInventoryName(INVENTORY_NOTECARD, 0));

updateHistoryList(name);

}
}
timer () {
string strHistoryReport = printHistoryList();

if ( llSubStringIndex(strHistoryReport, "Nothing to report.") != 0) // If the list wasn't empty
{
string strGameName = llGetObjectName();
strHistoryReport = strGameName + " report: " + strHistoryReport;
llEmail(strReportEmail, "Euttum Report", strHistoryReport);
lstHistory = [];
}
llSetTimerEvent( iReportFrequency ); //reset report timer
}

}

Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
07-27-2006 19:40
Good script. Just for clarity, this is the minimum that's needed if you don't need e-mails.

CODE

default
{
state_entry()
{
llSetText("The Classic \nTouch me for a notecard\n buy Me for $120", <1,1,1>,1);
}


touch_start(integer total_number)
{
llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_NOTECARD, 0));
}
}



Edit: oops fixed a typo
_____________________
Prim Composer for 3dsMax
-- complete offline builder for prims and sculpties in 3ds Max
http://liferain.com/downloads/primcomposer/

Hierarchical Prim Archive (HPA)
-- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools.
https://liferain.com/projects/hpa