Jump to content

llGetSubString() question.


Kipz Arado
 Share

You are about to reply to a thread that has been inactive for 4045 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

if(llToLower(llGetSubString(msg,0,5))=="timer ")
        {
            lol = llGetSubString(msg,6,-1);
           
            llOwnerSay("Particles will poof every : " + lol + " seconds");
      
    }

So, I've been trying to create a poofer, which is basically an object that "shoots" particles out of it at set intervals. I was wondering if there is a way to make it so the script detects my variable "lol" and makes sure it is a float or integer. This will allow way more customization then stacking if statements ontop of one another basically saying "if owner says 30, itll be set to 30 seconds, if owner says 20, itll be 20 seconds" etc... This will allow them to say 24.5 seconds if they really wanted to. The problem I have with this is you can say "timer cat" and then the particles stop coming out because in the particle system it's looking for a time of cat, which obviously isn't realistic. is there a way I can make the script filter out what would actually be an integer or float, and otherwise say "thats not a viable input" or something along that line?

 

Thank you so much in advance for any questions and advice!

 

 

Link to comment
Share on other sites

You can just cast it to float and test for 0.

You can also be a little more robust by splitting the string into a list instead of using a fixed offset, that way you can tolerate multiple spaces. I'd probably do something like this:

list words = llParseString2List( msg, [ " " ], [] ); // that's a space between the quotes
if( llToLower( llList2String( words, 0 ) == "timer" )
{
float seconds = (float)llList2String( words, 1 ); // get the second part as string and cast to float, llList2Float will always return 0 here.

if( seconds > 0.0 && seconds < whatever_your_max_time_is )
{
// it's a good time, use it
}
// otherwise ignore it, the time was not a number or was too high or low
}

That'll ignore "time kitty", "time -2.4" and work for "time 1", "        time                 2.5     ", and so on.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4045 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...