Notes on using Lua script language in Delphi

Source: Internet
Author: User

 

1. if you want to use Lua in Delphi, if you do not understand the installation, you can choose not to install it. put the PAS file and two DLL files in the project directory, and add Lua to the uses part of the project.

 

2. If you want to run only one function in the file, it seems that you must first run the entire file, that is, you need to call the pcall function twice. This may be because a function list needs to be provided before running the function.

Lua_pcall (lua_script, 0, 0); <br/> lua_getglobal (lua_script, functionname); <br/> result: = lua_pcall (lua_script, 0, 1, 0 );

 

3. if a function parameter is in the form of table {1, 2, 3}, if you want to read the third value (3) In the table ), four functions must be used in the following order:

Lua_pushnumber (L, 3); // 3 indicates the 3rd-bit table <br/> lua_gettable (L,-2); //-2 indicates the position of the table in the stack. In this example, the table parameter is the last incoming stack, which is generally-1, but it is changed to-2 because it is pushed into another value, the table's position in the stack will be pushed out of the stack, and the value read from the table will go into the stack. <Br/> P: = lua_tostring (L,-1); // read the data at the top of the stack. <Br/> lua_pop (L, 1); // clear the stack.

 

 

4. There seem to be many Lua's Delphi translations. I useHttp://www.matrix44.de/lua/Download.

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.