Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

XyText Notecard Reader

Karl Dorance
Registered User
Join date: 24 Oct 2006
Posts: 4
04-06-2007 19:29
OK, I copied part of this script from the LSL wiki to create a notecard reader that will change the text on the XyText prim by reading a notecard. I made it so that everytime one changes the entry in the notecard the scripting will automatically read the notecard and post the new changes to the XyText prim. I'd like y'all to take a look at this and let me know what you think and please post any modifications that you think will improve the scripting. Thanks.

CODE
// Pulled this script from the LSL Wiki and modified it for use with
// XyText as a notecard reader to set the text on the prim.
// April 6, 2007

// SampleSettingsReader.lsl
// Written by Konigmann Lippmann
// Thanks to Apotheus Silverman for his MultiItem Vendor...
// It seems like everything I write is based on it in one way or another.


// Default values
integer DISPLAY_STRING = 204000;
integer iShowHoverText = TRUE;
string sHoverTextValue = "Off";


// Globals
integer iNotecardIndex;
integer iNotecardCount;
integer iNoteCardLine;
key kCurrentDataRequest;
string sSettingsNotecard;


integer StringLeftICompare( string sLeftMatch, string sLongString )
{
integer iLength;

iLength = llStringLength( sLeftMatch ) - 1;
if( llToLower(llGetSubString( sLongString, 0, iLength ) ) == llToLower(sLeftMatch) )
return( TRUE );
return( FALSE );
}


string GetValue( string sString )
{
integer iStart;
string sValue = "";
string sbValue = "";

iStart = llSubStringIndex( sString, "=" ) + 1;
if( iStart )
{
sValue = llGetSubString( sString, iStart, llStringLength(sString) - 1 );
if( sValue )
{
sbValue = llToLower( sValue );
if( sbValue == "true" )
sValue = "1";
if( sbValue == "false" )
sValue = "0";
return( sValue );
}
}
return( NULL_KEY );
}


default
{
on_rez( integer param )
{
llResetScript();
}

state_entry()
{
integer iii;

llMessageLinked(LINK_SET, DISPLAY_STRING, "Setup", "");

iNotecardCount = llGetInventoryNumber( INVENTORY_NOTECARD );
iNotecardIndex = 0;
if( iNotecardCount > iNotecardIndex )
{
sSettingsNotecard = llGetInventoryName( INVENTORY_NOTECARD, iNotecardIndex );
iNoteCardLine = 0;
kCurrentDataRequest = llGetNotecardLine( sSettingsNotecard, iNoteCardLine );
iNotecardIndex++;
}
if( iNotecardIndex == 0 )
{
llWhisper( 0, "Using Default Values." );
state run_object;
}
}

dataserver( key kQuery, string sData )
{
list lSetting;

kCurrentDataRequest = "";
if( sData != EOF )
{
// you can string several of these tests for whatever values you may want.

if( StringLeftICompare( "ShowHoverText=", sData ) )
iShowHoverText = (integer)GetValue( sData );

else if( StringLeftICompare( "HoverTextValue=", sData ) )
sHoverTextValue = (string)GetValue( sData );

kCurrentDataRequest = llGetNotecardLine( sSettingsNotecard, ++iNoteCardLine );
}
else
{
iNotecardIndex++;
if( iNotecardIndex < llGetInventoryNumber( INVENTORY_NOTECARD ) )
{
sSettingsNotecard = llGetInventoryName( INVENTORY_NOTECARD, iNotecardIndex );

iNoteCardLine = 0;
llGetNotecardLine( sSettingsNotecard, iNoteCardLine );
}
else
{
state run_object;
}
}
}
}


// This is where your actual code would go
state run_object
{
state_entry()
{
if( TRUE == iShowHoverText )
llMessageLinked(LINK_SET, DISPLAY_STRING, sHoverTextValue, "");
else
llMessageLinked(LINK_SET, DISPLAY_STRING, "Off", "");
}
changed(integer change)
{
if(change == CHANGED_INVENTORY)
llResetScript();
}
}
Marty Starbrook
NOW MADE WITH COCO
Join date: 10 Dec 2006
Posts: 523
08-18-2007 12:15
Looks great ... if only I could get it to work *lol*

Marty
_____________________
Loves to drink Chokolate Latte at 2am GMT

SB Lighting ...... Im so cheap i cant afford signatures