generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Matching words against a part name?

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
27 Sep 2014 06:31 PM
I have one function already made that paints parts depending on their name, regardless of what model they're in. (I can give you the script if you want a copy of it. It's rather impressive in my opinion)

The function targets parts if they are specifically named "Primary Color"
but I was hoping someone had a way to target said parts if they simply had the word Primary somewhere in their name.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
27 Sep 2014 06:33 PM
local str = 'THIS IS NOT A PRIMARY COLOR'


function toboolean(v)
return v and true or false
end

print(toboolean(str:lower():match'primary'))
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
27 Sep 2014 06:42 PM
Ok that's a better example than the wiki gave me about the match method.


It's as simple as:

if Part.Name:match("Primary") then
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
27 Sep 2014 06:44 PM
That will match with the EXACT format of "Primary"

the way I did it made it so PRIMARY works

or primary

or pRimAry.



Also, the match function includes Lua's version of Regular Expressions (String Pattern) that allows you to do fancy matching for specific matches of characters which is why it is so complex.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
27 Sep 2014 06:47 PM
The exact pattern works fine for me. I kinda have OCD anyways... xD Or I'm a grammar knot-zee


Probably both.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
27 Sep 2014 07:06 PM
By the way I forgot to say thank you.

So... Thank you. :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image