Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help understanding this
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#2
RE: Need help understanding this

Technically, a string is generally a char array. In other words, "some text" is the same as {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'}. Therefore a character in a string can be accessed by its index; starting from 0 if read from left to right, starting from -1 if read from right to left. The numbers you're providing in StringSub() is the starting index and the number of characters you want to include from that index. So, StringSub("some text", 4, 2) will return " t".

You do not want to go passed the size of the string itself, as this may crash the game. So try to avoid using string.length() for the third parameter. Also, do note that providing -1 for the third parameter will tell the function to stop at the end of the string. So, StringSub("some text", 4, -1) will return " text"; StringSub("some text", 4, -2) will return " tex"; and so on.

Tutorials: From Noob to Pro
01-20-2012, 11:28 AM
Website Find Reply


Messages In This Thread
Need help understanding this - by Shadowfied - 01-20-2012, 10:06 AM
RE: Need help understanding this - by Your Computer - 01-20-2012, 11:28 AM
RE: Need help understanding this - by Shadowfied - 01-20-2012, 11:56 AM



Users browsing this thread: 1 Guest(s)