Many of the Lua game scripts are required to log in to a number of trumpets, which are typically stored in a document that needs to be read when the script is run.
Here is a txt document, record this account and password data, as follows
In which, the left for the account, the right for the password, the middle space separated (the number of space is not determined). Account allows the use of Chinese and English, numbers, symbols (but not allowed to have spaces), the password allows the use of English, numerals, symbols (allow a space, but not allowed to appear in the front or the last), ignore each line of the trailing space.
The following test on the computer, because my computer's operating system is a simplified version of Windows, that is, the system's character encoding for GBK. And the mobile phone uses the character code one edition is UTF-8 (specially must note this!)
In order to avoid garbled, TXT documents and LUA files are used in the same code as the system character encoding (very important!)
For GBK encoded systems, when saving, select ANSI (this format is the default for Notepad)
If you are running on a mobile phone, select UTF-8
LUA implementation:
Run Result:
Slightly modified to apply to the mobile phone, here with iOS as a demo:
Log:
The main difficulty of this program is to read the iterator lines () function, trim () function implementation, account password matching, table operation.
The custom function used in the String.Trim () we can remember that it is convenient to call in their own programs, or quite practical.