Lua account password Read script implementation tutorial

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.