Offline
Reads a notecard with a supplied name.
It will ignore all lines that are blank
It will ignore all lines which start with a #
and any lines with do not contain an = sign
Then it will clean up the bits either side of the equals sign to try and account for user inconsistencies.
If you are reading numbers, vectors or rotations don't forget to combine these with the mehods in my last few threads to validate the user provided you with a valid entry!
ProcessInstructionLine(string instruction, string data)
{
/*
This is where you add code to process the instuction based on the notecard content.
For example if this is a notecard containing a list of names who need to be on an access list
you might have a line like:
if (instruction == "name") accessList += data;
*/
}
ReadConfigCards(string notecardName)
{ // reads the config cards and restores the settings
if (llGetInventoryType(notecardName) == INVENTORY_NOTECARD)
{ //come here if the requested notecard exists in the inventory
integer notecardLength = osGetNumberOfNotecardLines(notecardName);
integer index;
for (index = 0; index < notecardLength; ++index)
{
string currentLine = osGetNotecardLine(notecardName,index);
string firstChar = llGetSubString(currentLine, 0,0);
integer equalsIndex = llSubStringIndex(currentLine, "=");
if (currentLine != "" && firstChar != "#" && equalsIndex != -1 )
{
//come here if the line is not blank AND
//the first character is not "#" AND
//the line contains an "=" sign.
string instruction = llGetSubString (currentLine, 0, equalsIndex-1); //everything before the equals sign
string data = llGetSubString(currentLine, equalsIndex+1, -1); //everyting after the euquals sign
//now lets clean up the information by trying to work around typoneese and carelessness
// we will remove any excess spaces and convert to lower case
instruction = CleanUpString (instruction);
data = CleanUpString (data);
ProcessInstructionLine(instruction, data); //sends the clean information to the process method
}
}
}//close if notecard exists in inventory
else llOwnerSay ("The notecard called " + notecardName + " is missing, please address this");
}//close reading config cards
string CleanUpString(string inputString)
{ // removes the white space and converts a supplied string to lower case
string cleanString = llStringTrim( llToLower(inputString), STRING_TRIM );
return cleanString;
}//close clean up string
default
{
state_entry()
{
//change the name of the configCard name to the name of the card you wish to read
ReadConfigCards("configCardName");
}
}
Last edited by sara (6/27/2019 2:30 pm)
Offline
asd asd fas asd asd
Offline
asd asd asd asd asd asd asd asd asd
Offline
asd asd asdasd sa
Offline
asd asd asd asd asd asd
Offline
asdf asd asd asd sad asd asd asd asd asd asd s
Offline
sdasd asd asdasdasd asd asd asd asd asd asd
Offline
ad asdasd ada sdasadfssaf asfasdfasdfaf afasdf asdf adfasdfasdfa
Offline
sad asd as asda sda fsf
Offline
xcvxcv xcv xcv xg dsgdfg sdg sdfg