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 » Scripters
Home Search
 

Re: Can someone make this shorter?

Previous Thread :: Next Thread 
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
31 Mar 2015 05:28 PM
It seems kinda long and I was wondering if there's a better way to do it.

Basically, it's checking to see if the first part of string1 is the same as string2

Note: I do not want to add any shortening of the names, I'm talking about a different way to do this.(So not :lower(),:len(), etc..)

local function ishort(name1,name2)
return string.lower(string.sub(name1,1,string.len(name2))) == string.lower(name2)
end
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
31 Mar 2015 05:31 PM
Example:

ishort("Frank","fan") -- true
ishort("Potato","corn") -- false
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
31 Mar 2015 05:31 PM
Can you teach me the context to why you used the math you did in Radar.

~Random SIGGY
Report Abuse
jewelycat is not online. jewelycat
Joined: 10 Sep 2008
Total Posts: 17345
31 Mar 2015 05:34 PM
It's a single-line function... What exactly do you want?

local function ishort(name1,name2)
return name1:lower():sub(1,#name2)==name2:lower()
end

also 2bad4u
Report Abuse
jewelycat is not online. jewelycat
Joined: 10 Sep 2008
Total Posts: 17345
31 Mar 2015 05:37 PM
return name1:lower():match(name2:lower())~=nil

kinda pointless to use string.match here tho...
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
31 Mar 2015 05:38 PM
"Can you teach me the context to why you used the math you did in Radar."

I don't understand what you're really asking but basically I used the same principle that the size of the brick's could be compare and scaled to the size of the frame I put them. The same way guis are can be scaled without using the scale property, just by dividing by the total size.
So I took that, flipped it, and did some math with dividing the x and z by the total size of the area I was viewing with the region3 and then using scale.
I haven't seen my code there in a while so I might not be 100% accurate here.


Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
31 Mar 2015 05:39 PM
Note: I do not want to add any shortening of the names, I'm talking about a different way to do this.(So not :lower(),:len(), etc..)


I could easily do this I just wanted to know if there was a shorterway.
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
31 Mar 2015 05:40 PM
Wait.. # works on strings too?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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