Treasure hunt scripts

 

This is the script for a wearable hud that works with other game features as well. For this example we will use it just to collect tokens for finding gems. You would put this in a wearable object like jewelry,  a badge or a hat etc.

// The actual HUD //
// ——————————————–
// ——————————————–
// declare / define global variables //

integer pCoins = 0;
integer pGems = 0;
integer pScore = 0;
string vhCustomTitle = “Tresure Hunt”;
string vhTitleOffset = ” \n \nThanks for trying the Game Kit.\nBegin by collecting gem.”;
string vhMessageLine = “\n \n “;
string vhCoinString = “”;
string vhGemString = “”;
string vhScoreString = “”;
integer vhAccessCost = 0;
list pPuzzleList = [];
integer pHUDworn = 0;
string gsCardOneName = “config”;
string g_sNoteCardName;
list gOneCard;
list g_lTempLines;
integer g_iLine;
key g_kQuery;

initialize(string _action) {
if (_action == “”) {
loadNoteCard(gsCardOneName);
} else if (_action == “finish”) {
integer i;
for (i = 0; i< 7; ++i)
{
string tLineText = llList2String(gOneCard,i);
if (i == 0)
{
vhAccessCost = (integer)right(tLineText,”:”);
}
if (i == 1)
{
vhCustomTitle = right(tLineText,”:”);
vhCustomTitle = vhCustomTitle + “\n “;
}
if (i == 2)
{
vhTitleOffset = right(tLineText,”:”);
vhTitleOffset = vhTitleOffset + “\n \n “;
}
llListen(999,””, “”,””);
//llListen(reset_channel, “”, “”, “”); // RESET channel

}
}
}

loadNoteCard( string _notecard ) {
g_lTempLines = [];
g_sNoteCardName = _notecard;
g_iLine = 0;
g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine);

}

notecardFinished(string _notecard){
if (_notecard == gsCardOneName) {
gOneCard = g_lTempLines;
initialize(“finish”);
}
}

// ——————————————–
// ——————————————–
// define global custom functions //
// these are from the lsl tutorials //

string left(string src, string divider) {
//llSubStringIndex
// find the first appearance of the divider
integer indexLF1 = llSubStringIndex( src, divider );
if(~indexLF1)
// check to see that the appearance falls in a positive number position
//string llDeleteSubString(string src, integer start, integer end)
// remove all of the text that falls to the right of the first divider
return llDeleteSubString( src, indexLF1 + llStringLength(divider)-1, -1);
return src;

}

string right(string src, string divider) {
integer index = llSubStringIndex( src, divider );
string tString = “”;
if (~index)
{
// this fetches the string to the right of the first marker
tString = llDeleteSubString( src, 0, index + llStringLength(divider) – 1);
//llSay(0,”whats left ” + src);
// now we need to get the right half of that
integer indexSR1 = llSubStringIndex(tString, divider);
if (~indexSR1)
{
// here’s the far right side of a 3 part list
tString = llDeleteSubString(tString, 0, indexSR1 + llStringLength(divider) – 1);
}
}
return tString;
}

string center(string src, string divider) {
integer index = llSubStringIndex( src, divider );
string tString2 = “”;
if(~index)
{
tString2 = llDeleteSubString( src, 0, index + llStringLength(divider) – 1);
integer indexC1 = llSubStringIndex(tString2, divider);
if (~indexC1)
{
return llDeleteSubString( tString2, indexC1 + llStringLength(divider)-1, -1);
}
}
return tString2;
}

default
{
on_rez(integer start_param)
{

if (llGetAttached() > 30)
{
pHUDworn = 1;
initialize(“”);
llSetText(vhCustomTitle + vhTitleOffset + “\n \n “, <0,0,0>, 1);
}else{
llSetText(“”, <0,0,0>, 1);
llSay(0, (string)llGetAttached());
}

}
state_entry()
{
initialize(“”);
integer messageInt = llListen(1717, “”, NULL_KEY, “” );
integer messageInt2 = llListen(1718, “”, NULL_KEY, “” );
integer messageInt3 = llListen(1719, “”, NULL_KEY, “”);
integer messageInt4 = llListen(1791, “”, NULL_KEY, “”);
integer messageInt5 = llListen(1616, “”, NULL_KEY, “”);
integer messageInt6 = llListen(2654, “”, NULL_KEY, “” );
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;
}

touch_start(integer total_number)
{
// if they touch the scorekeeping object – readout the scores
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;
if (pHUDworn == 1)
{
llSetText(vhCustomTitle+vhMessageLine+vhCoinString+vhGemString+vhScoreString, <0,0,0>, 1);
}else{
llInstantMessage(llGetOwner(),vhCustomTitle+vhMessageLine+vhCoinString+vhGemString+vhScoreString);
}
}

listen( integer channel, string name, key id, string message )
{
if (channel == 1717)
//llSay(0, (string)channel + ” ” + name + ” ” + (string)id + ” ” + message);
{
string mesR = right(message, “:”);
string mesL = left(message, “:”);
string mesC = center(message, “:”);
integer tValue = (integer)mesR; // convert the coin string to a number
//llSay(0, (string)llGetOwner());
//llSay(0, mesL);
if (mesL == (string)llGetOwner())

// this is the parse for hud owner messages only
{
//llSay(0, “LINE 110: ” +(string)tValue);
pCoins = pCoins + tValue;
// fix according to positive v negative values
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;
if (pHUDworn == 1)
{
llSetText(vhCustomTitle+vhMessageLine+mesC+vhCoinString+vhGemString+vhScoreString, <0,0,0>, 1);
}else{
llInstantMessage(llGetOwner(), vhCustomTitle+vhMessageLine+mesC+vhCoinString+vhGemString+vhScoreString);
}
}
// llSay(0, (string)pCoins);
}

if (channel == 1718)
{
string mesR = right(message, “:”);
string mesL = left(message, “:”);
string mesC = center(message, “:”);
integer tValue = (integer)mesR; // convert the coin string to a number
//llSay(0, mesL);
//llSay(0, (string)llGetOwner());
if (mesL == (string)llGetOwner())
{
if (tValue > 0)
{
if (pCoins >= tValue)
{
//llSay(0, “LINE 132: ” +(string)tValue);
pCoins = pCoins – tValue;
}else{
pCoins = 0;
}
}
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;

if (pHUDworn == 1)
{
llSetText(vhCustomTitle+vhMessageLine+mesC+vhCoinString+vhGemString+vhScoreString, <0,0,0>, 1);
}else{
llInstantMessage(llGetOwner(), vhCustomTitle+vhMessageLine+mesC+vhCoinString+vhGemString+vhScoreString);
}
}
}

if (channel ==1719)
{
if (message == (string)llGetOwner())
{

if (pCoins >= vhAccessCost)
{
pCoins = pCoins – vhAccessCost;
llSay(1720, “Y”);
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;
if (pHUDworn == 1)
{
llSetText(vhCustomTitle+vhMessageLine+”You spent “+ (string)vhAccessCost+ ” tokens to use this object.” +vhCoinString+vhGemString+vhScoreString, <0,0,0>, 1);
}else{
llSay(0, vhCustomTitle+vhMessageLine+”You spent “+ (string)vhAccessCost+ ” tokens to use this object.” +vhCoinString+vhGemString+vhScoreString);
}
}else{
llSay(1720, “N”);
}
}
}

if (channel == 1791)
{
if (message == (string)llGetOwner())
{
// here we should add a list to hold which objects have been acquired. We can do it by storing a list of the
// puzzle boards that awarded gems – and simply ignoring repeat awards – (you could add a message to that effect as well.
list tTest = [id]; // the uuid of the puzzle board
integer foundIndex = llListFindList(pPuzzleList, tTest);
if (foundIndex == -1)
{
pGems = pGems+1;
list insertNameList = [id];
pPuzzleList = llListInsertList(pPuzzleList, insertNameList, 0);
vhCoinString = “\nTOKENS: “+(string)pCoins;
vhGemString = “\nPRIZES: “+(string)pGems;
pScore = pCoins * pGems;
vhScoreString = “\nPOINTS: “+(string)pScore;
if (pHUDworn == 1)
{
llSetText(vhCustomTitle+vhMessageLine+”You earned a prize.”+vhCoinString+vhGemString+vhScoreString, <0,0,0>, 1);
}else{
llInstantMessage(llGetOwner(), vhCustomTitle+vhMessageLine+”You earned a prize.”+vhCoinString+vhGemString+vhScoreString);
}
}else{
llInstantMessage(llGetOwner(), “You have already earned this prize.”);
}
}else{

//llSay(0, message);
key tKeyMes = (key)message;
list tTest = [tKeyMes];
//llSay(0, (string)pPuzzleList);
//llSay(0, (string)tTest);
integer foundIndex = llListFindList(pPuzzleList, tTest);
//llSay(0, (string)foundIndex);
llSay(3719, (string)foundIndex);
}

}
if (channel == 1616)
{
string whoCalled = right(message, “:”);
if (whoCalled == “board”)
{
llSay(1617, ((string)pCoins + “:” + (string)pGems));
}else{
llSay(1417, ((string)pCoins + “:” + (string)pGems));
}
}

if (channel == 2654)
{
llSay(2655, “ScorekeeperReply”);
}

}
dataserver(key _query_id, string _data)
{
if (_query_id == g_kQuery) {
if (_data != EOF) {
g_lTempLines += [_data];
g_iLine++;
g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine);
} else {
notecardFinished(g_sNoteCardName);
}
}
}

}


 

This is the notecard you would include in the object as well. Title in config

 

// PAY BOARDS TO PLAY // :5
// HUD GAME TITLE // :Treasure Hunt Game
// INSTRUCTIONS // : Collect gems.


 

And now for the treasure token script put this inside any object you want to award tokens for finding.

 

string pCoinValue = “30”; // um, change the number to make it worth more or less
string pAcquireMessage = “Follow the gems.”; // change the text inside quotes to make it say something different
string CONTROLLER_ID = “A”;
float tAlpha = 0.8; // set this to 1.0 if you want your object to be fully opaque.
// for the adventurous, you could make a random list and choose different things to say
string gsCardOneName = “config”;
list gOneCard;
list g_lTempLines;
string g_sNoteCardName;
integer g_iLine;
string g_kQuery;
integer resetChannel = 3;
integer respawnDelay = 30;
string vhUseParticles = “TRUE”;
float vhTargetOmega = 0.3;

 

//—————– PRIVATE —————————–
string left(string src, string divider) {
integer index = llSubStringIndex( src, divider );
if(~index)
{
return llDeleteSubString( src, index + llStringLength(divider)-1, -1);
}
return src;
}

string right(string src, string divider) {
integer index = llSubStringIndex( src, divider );
string tString = “”;
if (~index)
{
return llDeleteSubString( src, 0, index + llStringLength(divider) – 1);
}
return tString;
}

initialize(string _action) {
if (_action == “”) {
//llSay(0, “1”);
loadNoteCard(gsCardOneName);
} else if (_action == “finish”) {
//llSay(0, “2”);
integer i;
for (i = 0; i< 7; ++i)
{
string tLineText = llList2String(gOneCard,i);
if (i == 0)
{
pCoinValue = right(tLineText,”:”);
}
if (i == 1)
{
pAcquireMessage = right(tLineText,”:”);
}
if (i == 2)
{
string tAlphaString = right(tLineText,”:”);
tAlpha = (float)tAlphaString;
}
if (i == 3)
{
string stresetChannel = right(tLineText, “:”);
resetChannel = (integer)stresetChannel;
integer lHandle5 = llListen(resetChannel, “”,””,””);
}
if (i == 4)
{
string stRespawnDelay = right(tLineText, “:”);
respawnDelay = (integer)stRespawnDelay;
//llSay(0, stRespawnDelay);
}
if (i == 5)
{
vhUseParticles = right(tLineText, “:”);
if (vhUseParticles == “TRUE”)
{
llMessageLinked( LINK_SET, TRUE, CONTROLLER_ID, NULL_KEY );
}else{
llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );
}
}
if (i == 6)
{
string stvhTargetOmega = right(tLineText, “:”);
vhTargetOmega = (float)stvhTargetOmega;
llTargetOmega(<0,0,vhTargetOmega>, 10, 10);
}
}
}
}

loadNoteCard( string _notecard ) {
g_lTempLines = [];
g_sNoteCardName = _notecard;
g_iLine = 0;
g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine);
}

notecardFinished(string _notecard){
if (_notecard == gsCardOneName) {
gOneCard = g_lTempLines;
initialize(“finish”);
}
}
//——————————————–

 

default
{
state_entry()
//
{
initialize(“”);
// on stateChange do stuff
//integer lHandle5 = llListen(resetChannel, “”,””,””);
llSetLinkAlpha(LINK_SET, tAlpha, ALL_SIDES);
// set entire prim 100% visible.
//llTargetOmega(<0,0,vhTargetOmega>, 10, 10);
llSetStatus(STATUS_PHANTOM, TRUE);
llSetStatus(STATUS_ROTATE_Z, TRUE);
llTargetOmega(<0,0,vhTargetOmega>, 10, 10);
llVolumeDetect(TRUE);
}
touch_start(integer total_number)

{
float tAlpha = (llGetAlpha(ALL_SIDES/llGetNumberOfSides()));
//llSay(0,(string)tAlpha);
if (tAlpha>0.0)
{
//llInstantMessage(llDetectedKey(0), “You picked up a Spanish Doubloon!”);
// make it invisible
llSetAlpha(0.0, ALL_SIDES);llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
// set entire prim 100% invisible.
llSetStatus(STATUS_ROTATE_Z, FALSE);
llSetStatus(STATUS_PHANTOM, TRUE);
// make it non-physical
// start a timer
// make it reappear after n seconds (n=60)
if (respawnDelay > 0)
{
llSetTimerEvent(respawnDelay);
}
// send a message to the gatherer’s HUD to add 1 coin
llSay(1717, ((string) llDetectedKey(0) + “:” + pAcquireMessage + “:” + pCoinValue));
llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );
//llSay(0, ((string) llDetectedKey(0) + “:” + pAcquireMessage + “:” + pCoinValue));
// llSay(1717, ((string) llDetectedKey(0) + “: 100”)); // would also work now or any integer positive or negative for that matter.
}

}
collision_start(integer num_detected)
{
float tAlpha = (llGetAlpha(ALL_SIDES/llGetNumberOfSides()));
if (tAlpha>0.0)
{
//llInstantMessage(llDetectedKey(0), “You picked up a Spanish Doubloon!”);
// make it invisible
llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
// set entire prim 100% invisible.
llSetStatus(STATUS_ROTATE_Z, FALSE);
llSetStatus(STATUS_PHANTOM, TRUE);

if (respawnDelay > 0)
{
llSetTimerEvent(respawnDelay);
}
llSay(1717, ((string) llDetectedKey(0) + “:” + pAcquireMessage + “:” + pCoinValue));
llVolumeDetect(FALSE);

llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );
}
}
//////
listen(integer channel, string name, key id, string mes)
{

if (channel == resetChannel)
{
initialize(“”);
llSay(0, “Okay, I reset the token”);
llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
if (vhUseParticles == “TRUE”)
{
llMessageLinked( LINK_SET, TRUE, CONTROLLER_ID, NULL_KEY );
}else{
llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );
}
llSetStatus(STATUS_PHANTOM, TRUE);
llVolumeDetect(TRUE);
//llSetTimerEvent(0);

}
}
//////////

timer()
{
//llResetScript();
llSetLinkAlpha(LINK_SET, tAlpha, ALL_SIDES);
if (vhUseParticles == “TRUE”)
{
llMessageLinked( LINK_SET, TRUE, CONTROLLER_ID, NULL_KEY );
}else{
llMessageLinked( LINK_SET, FALSE, CONTROLLER_ID, NULL_KEY );
}
llVolumeDetect(TRUE);
llSetStatus(STATUS_PHANTOM, TRUE);
llSleep(1);
llSetTimerEvent(0);
}
dataserver(key _query_id, string _data)
{
if (_query_id == g_kQuery) {
if (_data != EOF) {
g_lTempLines += [_data];
g_iLine++;
g_kQuery = llGetNotecardLine(g_sNoteCardName, g_iLine);
} else {
notecardFinished(g_sNoteCardName);
}
}
}
}

 

———————————————————————————————————————————————————————————————————————————————————————————-and the notecard for the token is also titled config

How many credits is this token worth? :30
What message should this token say? :Nice find! These Gems will help you on your path.
How opaque is this token?(range is 0.0-1.0) :1.0
What channel number should be used for reset? :3
How many seconds delay before respawning? :30
The token should use particles? (TRUE or FALSE) :TRUE
Speed / direction of spin? (range -1.000 – 1.000) :0.0
// never delete a colon
// Spin speed can be set to 0.0 for no spin
// If you use a HUD, message length should not be longer than about 60 characters.
// resetting any value above is entirely optional.
// Set respawn delay to a negative integer to prevent respawning
// You can reset any token using the channel defined above (if for example you left it channel 3, type ‘/3 ‘ and enter

 

Advertisements

Would you love me anyway?

Would you think me ill if I laughed to loud?

Would you shame me if I cried?

If the truth would hurt and could not help,

would you blame me if I lied?

Would you pick me up if I fell down

and would you join me on the ground

if I couldn’t get up and I was afraid,

would you love me anyway?

Who do you see

Who do you see when you look at me?
Do you see who I am and who I hope to be?
Who do you see when you look at me?
that you would condemn or hope to admire?
If you’re looking high, look lower.
If you’re looking low, look higher.
I am a child of anger...

 

Who do you see when you look at me?
Do you see who I am and who I hope to be?
Who do you see when you look at me?
that you would condemn or hope to admire?
If you’re looking high, look lower.
If you’re looking low, look higher.
I am a child of anger with a ones of her own,
A loving mother whose children adore.
Do you see a harlot, a disgrace to her home,
a devoted wife who could not be more?
Is that what you see when you look at me?
That you would condemn or you would admire?
If your looking high, look lower.
If your looking low, look higher.
Lazy in deed, even at play,
A loyal worker doing her best,
ashamed and alone, forgetting to pray,
A faithful Christian never at rest?
Whomever you see when you look at me,
do not condemn or hope to admire.
For all of who I am, it is all of me,
If you’re looking high, look lower.
If you’re looking low, look higher.