Hi,
I have a (very) basic question about Lua. I would like to get the next (or previous) of a given letter.
I have been looking around, but haven't found any answer. Is it possible?
Here is what i want to do :
I have a list of game names in an array, and a "currentGame" variable that indexes one of the games. I get the first letter of the name with something like "firstLetter = string.sub(gameName, 1, 1)", but then how do i get the ascii code (or equivalent) of this letter? With such code i could then get the next letter with "nextLetter = '\'..\code, then look in my array for a game starting with this letter.
For example, with a list like "Aero figters, altered beast, arkanoid, batsugun", and the current game being altered beast, i would like to get letter B.
I hope my english is good enough for you to understand :p
Thank you.
Next character in the alphabet
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Next character in the alphabet
Code: Select all
function next_ascii(letter)
local ascii_code = string.byte(letter)
local next_ascii_code = ascii_code + 1
return string.char(next_ascii_code)
end
Code: Select all
function next_ascii(letter)
return string.char(string.byte(letter)+1)
end
Re: Next character in the alphabet
Thank you,
I somehow failed to find the function that does like... exactly what i want
I somehow failed to find the function that does like... exactly what i want
Who is online
Users browsing this forum: Google [Bot] and 4 guests