|
| 23 Aug 2014 05:12 AM |
Im making a game that uses lots of string (the part's name is used)
basically, i need help editing string values for example,
text1 = "Plint_Fire" --i need to find out if its a plint. text:match("Plint_") --now i need to remove the part that says "Plint_" so that only "Fire" will be left in the string
the new string should be = "Fire"
--------- another example: text1 = "[S]SpecialEvent" check if match ("[S]") remove "[S]" from string newstring = "SpecialEvent" |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 23 Aug 2014 05:43 AM |
text1 = "Plint_Fire" --i need to find out if its a plint. if string.sub(text1, 1, 6) == "Plint_" then --now i need to remove the part that says "Plint_" so that only "Fire" will be left in the string text1 = "Fire" end |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 23 Aug 2014 05:43 AM |
| But if you are declaring text1 as Plint_Fire then the condition will always be true, just be aware of that. |
|
|
| Report Abuse |
|
|
IcyFires
|
  |
| Joined: 29 Jun 2013 |
| Total Posts: 5046 |
|
|
| 23 Aug 2014 05:45 AM |
Oh and if you want the second part to be flexible for renaming put:
text1 = string.sub(text1, 7) |
|
|
| Report Abuse |
|
|