Jump to content

code to seperate a letter out of a word


stepping stone

Recommended Posts

Hi,

 

Does somebody knows how to program this :ex. if I have the word "Wherigo", I want to look what the first letter of the word is, so in this example it's "w". Is there a way to check it?

Someone gives a word in player and I want to check the first letter of this word and use this letter to compare to another letter.

 

Thank you all

Link to comment

Perhaps I should have elaborated. The arguments in string.sub are:

1) The string from which you're getting a substring (i.e. getting the letter)

2) Counting from the left, the number of the first character you want to include. The numbering starts at 1.

3) The third argument tells lua the number of the last character, inclusive, to stop. I used 1 because you wanted just the first character. Alternatively, you could use a negative number to start counting from the back of the string. For instance string.sub(s,1,-2) would have returned "Wherig".

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...