IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 01 Aug 2012 12:56 AM |
| I have a bunch of values and in my script I use GetChildren() to search for the values with the number 1, 2 or 3.. but I'm thinking of changing it so that it searches for the first letter of the value. Like the value would be a60 or a12. I want to know how I can check if the first letter of the value is a because I'll have other values with other letters like b and c. Sorry if you're confused... I'm half asleep. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 01 Aug 2012 01:01 AM |
letter = "apples" if letter:sub(letter,1,1) == "a" then print("ye") end
Tired too you know :3 |
|
|
| Report Abuse |
|
|
IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 01 Aug 2012 01:01 AM |
| Would I be able to use string.gmatch? |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 01 Aug 2012 01:05 AM |
letter = "apples" for all in letter:gmatch("%l+") do if all == "a" then print("ye") end end
I'm tired, maybe? Probably not because I'm getting sleepy :3 |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 01 Aug 2012 01:08 AM |
| I would just use string.sub() |
|
|
| Report Abuse |
|
|
IlIll
|
  |
| Joined: 28 Aug 2011 |
| Total Posts: 896 |
|
|
| 01 Aug 2012 01:08 AM |
| Thanks! Have a nice rest... when you do sleep. |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 01 Aug 2012 01:10 AM |
In like another hour XP
It's bad health, but I'm skinny and have coffee. I'm already healthy XP |
|
|
| Report Abuse |
|
|
|
| 01 Aug 2012 01:16 AM |
string.sub(msg,1,2) is the advanced faster running one (tested)
msg:sub(1,2) is the simple medium running one (tested) |
|
|
| Report Abuse |
|
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
| |
|