|
| 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 |
|
|
|
| 31 Mar 2015 05:31 PM |
Example:
ishort("Frank","fan") -- true ishort("Potato","corn") -- false
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 31 Mar 2015 05:40 PM |
| Wait.. # works on strings too? |
|
|
| Report Abuse |
|
|