Neverworld Grid

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



6/26/2019 10:04 am  #1


Check if input is a ROTATION - ideal to include in your preprocessor

please note this method relies on you also including another method to check if a string is a float. This can be found in a previous post in this forum

#include "chkisrot.lsl"
integer isRot = ChkIsRot (string inputString)

integer ChkIsRot (string inputString)
{ // returns a true if supplied string is a vector and false if it is not
    /*
    Relies on you including
    chkisfloat.lsl
    */
    integer isRot;
    string startProcess = llStringTrim ((inputString), STRING_TRIM);
    integer stringLength = llStringLength(startProcess);
    integer openBraceIndex = llSubStringIndex(startProcess, "<");
    integer closeBraceIndex = llSubStringIndex(startProcess, ">");
    if (openBraceIndex == 0 && closeBraceIndex == stringLength-1 )
    {
        integer startIndex = openBraceIndex +1;
        integer endIndex = closeBraceIndex -1;
        startProcess = llGetSubString(startProcess, startIndex, endIndex); //removes the first and the last characters ("<" and ">")
        list stringParts = llCSV2List(startProcess); //turn the remaining list elements into a list
        string strX =  llStringTrim( (llList2String(stringParts,0)), STRING_TRIM); // new string for x with whitespace removed
        string strY =  llStringTrim( (llList2String(stringParts,1)), STRING_TRIM); // new string for y with whitespace removed
        string strZ =  llStringTrim( (llList2String(stringParts,2)), STRING_TRIM); // new string for z with whitespace removed
        string strS =  llStringTrim( (llList2String(stringParts,3)), STRING_TRIM); // new string for z with whitespace removed
        integer strXIsFloat =  ChkIsFloat(strX);
        integer strYIsFloat =  ChkIsFloat(strY);
        integer strZIsFloat =  ChkIsFloat(strZ);
        integer strSIsFloat =  ChkIsFloat(strS);
        if (strXIsFloat && strYIsFloat && strZIsFloat && strSIsFloat) isRot  = TRUE;
        else isRot  = FALSE;
    }
    else isRot = FALSE;
    return isRot;
}//close chk is a vector 

 

Board footera

 

Powered by Boardhost. Create a Free Forum