Jump to content

Parsing a string to a permission mask?


Ixia
 Share

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

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

Recommended Posts

Hi,

 

So i wanted to parse a string to a permission mask so like "mod/copy" would be parsed to whatever PERM_MODIFY | PERM_COPY equals to.

So i wondered if theres a better way to do this than something like

 

integer nPerms = ( ( llSubStringIndex( input, "mod" ) != -1 ) * PERM_MODIFY )
               | ( ( llSubStringIndex( input,"copy" ) != -1 ) * PERM_COPY )
               | ( ( llSubStringIndex( input,"transfer" ) != -1 ) * PERM_TRANSFER );

 

 

 

Link to comment
Share on other sites

Oh, I'm sure of the format, its just going to be a list of permission-words with whatever separation...

 

Just wondered if for the actual functionality there is a better way, cause that seems a little complicated ^^

Link to comment
Share on other sites

is there any special reason to need the actual constant values of PERM_* ? because offhand I only know 2 functions that can get them (llGet[inventory|Object]PermMask), and none that use them.

they are also equal to
1 << 13 (trans)
1 << 14 (mod)
1 << 15 (copy)
where 1 << -1 would be 0

but all those would be more complex than what you already have...

(!!~llSubStringIndex( input, "Mod' )) is the same as (llSubStringIndex( input, "Mod' ) != -1)... it's smaller, but it's 3 operations instead of 1 or 2, and harder to understand.

you could parse the who thing at once with llParseString2List( input, []. ["copy", "mod", "trans"] );, but then you still have to check that list to see which permissions it captured, so it's really just an extra step...

there are only 6 possible legal permission sets, so you could simply use a format that made those clear... and parse for that to get a value eg:

list    gLstPrm = ["[CMT]", "[CM]", "[CT]", "[MT]", "[C]", "[T]"];integer vIntPrm = llListFindList( gLstPrm, llParseString2List( input, [], gLstPrm ) );

 

that's about all I can think of though....

 

Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...