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
Shadowfied Offline
Senior Member

Posts: 261
Threads: 34
Joined: Jul 2010
Reputation: 5
#3
RE: Need help understanding this

(01-20-2012, 11:28 AM)Your Computer Wrote: 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.
Okay thanks, that helped me understand it a little bit.

Do you know how to make the script work?


Current - Castle Darkuan
Other - F*cked Map
01-20-2012, 11:56 AM
Find


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



Users browsing this thread: 1 Guest(s)