Neverworld Grid

You are not logged in. Would you like to login or register?



6/27/2019 2:26 pm  #1


config card reader - OSSL regions only

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)

 

9/24/2021 12:41 am  #2


Re: config card reader - OSSL regions only

asd asd fas asd asd 

 

9/24/2021 12:41 am  #3


Re: config card reader - OSSL regions only

asd asd asd asd asd asd asd asd asd

 

9/24/2021 12:43 am  #4


Re: config card reader - OSSL regions only

asd asd asdasd sa

 

9/24/2021 12:44 am  #5


Re: config card reader - OSSL regions only

asd asd asd asd asd asd

 

9/24/2021 12:46 am  #6


Re: config card reader - OSSL regions only

asdf asd asd asd sad asd asd asd asd asd asd s

 

9/24/2021 12:48 am  #7


Re: config card reader - OSSL regions only

sdasd asd asdasdasd asd asd asd asd asd asd

 

9/24/2021 12:50 am  #8


Re: config card reader - OSSL regions only

ad asdasd ada sdasadfssaf asfasdfasdfaf afasdf asdf adfasdfasdfa

 

9/24/2021 12:51 am  #9


Re: config card reader - OSSL regions only

sad asd as asda sda fsf 

 

9/24/2021 12:53 am  #10


Re: config card reader - OSSL regions only

xcvxcv xcv xcv xg dsgdfg sdg sdfg

 

Board footera

 

Powered by Boardhost. Create a Free Forum