Game Development Reference
In-Depth Information
string.byte ( s [,i [,j ] ] )
For the devices, a character is an ASCII number from 0 to 255. While we recognize characters as an
A or a , each character is represented with a number, such as 65, 97, and so on. The byte function
returns the number or the ASCII code of the character at the position in question. There are three
parameters that can be passed: the string itself ( s ) and the optional i and j ; i marks the start
position of the string (by default it is 1) and j marks the end of the string (its default is the same as i ).
Here's an example:
print(string.byte("One"))
print(string.byte("One",1,3))
. .)
loadstring function on the string and returns a copy of the function. Though
most of the frameworks allow loadstring , CoronaSDK has blocked this function, so there isn't much
that one can do with this if using CoronaSDK.
string.find ( s, pattern [,init [,plain] ] )
This function looks for the first match of the pattern in the string s . If found, it returns the indices
of where the match starts and ends. If a match is not found, it returns nil . The parameter init (if
passed) determines the starting position of the search. The default value for this is 1. The parameter
for plain is a Boolean value that is either true or false . This determines if pattern is false ; it is just
plain text for substring matching. If this is true , then pattern can have placeholders and wildcards
for matching. If pattern has captures, then the function returns the captured values after the two
indices.
string.format ( formatString, . . . )
This function returns a string that is formatted based on the format and the values passed. This is
similar to the C function printf . The options/modifiers * , l , L , n , p , and h are not supported. This
function has a new option, q , that formats the string in a form that is suitable and safe for use with
the Lua interpreter. All the characters are correctly escaped to work. For example
string.format('%q', 'a string with "quotes" and \n new line')
will produce the string
 
Search WWH ::




Custom Search