In this article, I want to show you how to do LUA programming. I assume that everyone has learned at least one programming language, such as Basic or C, especially C. Because the maximum use of LUA is used as a script in the host program.Lua's syntax is relatively simple, learning is also relatively labor-saving, but the function is not weak.In Lua, everything is
In general, you don't need to know the details of the LUA implementation table, so you can use it. In fact, Lua spends a lot of time hiding the inner implementation details. However, implementation details reveal the performance overhead of table operations. Therefore, to optimize the program that uses the table (especially the LUA program), it is good to know so
1. OverviewThread as a basic data type in Lua, which represents a separate thread of execution (independent threads of execution), the thread type is the basis of the Implementation Association (COROUTINES). Note that the thread type here is not confused with the operating system thread, and Lua's thread type is a data type implemented by the LUA virtual machine.From the
In reality, game development often faces two conflicting pressures: Testing and verifying new ideas, and fast development and delivery.Integrating the scripting language into a game project can improve the development efficiency of the team and expand the native compilation language capability. Lua has performed well in many basic fields of game development.
In the game development team, many members may use Lua
--Suggest using notepad++ to open the language to LUAIn Lua, everything is a variable, except for keywords. Please remember this sentence.I. First is the commentWriting a program is always a comment.In Lua, you can use single-line comments and multiline comments.In a single-line comment, a continuous two minus "--" indicates the beginning of the comment and continues until the end of the line. Equivalent to
Lua's syntax is relatively simple and easier to learn, but its functions are not weak.
In Lua, everything is a variable except a keyword. Remember this sentence.
I. annotation first
Writing a program is always without comments.
In Lua, you can use single-line and multi-line annotations.
In a single line comment, two consecutive minus signs "--" indicate the start of the comment until the end of the line. I
Lua is a lovely scripting language made up of Roberto Ierusalimschy, Waldemar Celes and Luiz Henrique de Figueiredo and developed in 1993. It is designed to embed applications (most referred to as hot updates)to provide flexible extension and customization capabilities for applications. The Luainterface Lua language is a library integration and Microsoft. The common language Runtime (CLR) of the network pla
IdeasLike all languages, a binding callback is primarily performed when a task executes to a specific situation, invoking the callback method. It's the same here. The core idea is that when C code executes to a specific situation, the method of invoking LuaThe main steps are as follows
A reference to the cache Lua function in a LUA environment
Set the callback in the C code place in C's Way
GamesThe script language has become a standard application. The script language canGamesDevelopers play an important role in Data structuring, planning events, testing, and debugging. The scripting language can also allow non-procedural experts like art to use a high-level abstract scriptGamesWrite code. Part of this abstraction layer can also be provided to players to customize the entireGames.
From the programmer's point of view, the main problem in embedding a scripting language into a game i
What type of function can be called by Luaint (*lua_cfunction) (Lua_state *l);How a function of a conforming type can be called by LuaUse Lua_register or Lua_pushfunction and Lua_setglobal () to add the function to be called to the Lua state machine.#define Lua_register (l,n,f)/ (Lua_pushcfunction (L, F), Lua_setglobal (l, N))The second parameter of Lua_register is the name of the call to this function in the
Accidentally heading the party again? Sorry, ha ~Look over the previous blog, send a lot of nonsense too many of their own can not see, ah, well, as far as possible to write a little more concise.This article does not involve LUA grammar learning, if necessary, please visit: http://book.luaer.cn/A. Lua stackTo understand Lua and C + + interactions, first understa
Often see some games can change something without appstore, such as adding functionality.This is actually done by downloading the script. The common script is JS and Lua.Individuals are more familiar with Lua.Lua is still a bull, the interpreter is very small, the speed is very fast, and the C language function of the interaction is also easy.Integrating LUA into Xcode engineeringVery easy,1. To the LUA web
LuaWithC ++: Basic Lua syntax, luawithcluaProcedure
1. The host language creates a Lua interpreter (lua state machine) object.
2. register the Lua extensions (if any) implemented by the host language, such as functions, to the Lua interpreter for use.
3. Read the
From the point of view of use, a module is a library of libraries that can be loaded through the require provided by LUA itself. Then we get a global variable that represents a table. This table is like a namespace, and its contents are everything that the module exports, such as functions and constants. Simply put, the module in Lua is a table,table that can include anything. In this paper, the Require fun
It's simple to introduce a few this time, but be sure to return the value rule carefully.
1.resume of parameters
The resume function can continue to pass other parameters besides the first parameter, the following code:
Copy Code code as follows:
Local CO = coroutine.create (function (name)
print (name);
End);
Coroutine.resume (CO, "resume Param");
Resume the second parameter is "Resume Parame", which is passed to the function of the synergistic program.The output
Lua Game Development Practice GuideBasic InformationOriginal Title: Game Development with LuaAuthor: (US) Paul schuytema mark manyenTranslator: Tian JianSeries name: Chapter Hua programmer LibraryPress: Machinery Industry PressISBN: 9787111403357Mounting time:Published on: February 1, January 2013Start: 16Page number: 1Version: 1-1Category: Computer
For more information, Lua game development practicesIntrod
Write by nine days Yan Ling (jtianling) -- blog.csdn.net/vagrxie
Discuss newsgroups and documentsPreface
Take the jsoncpp library as an example in data/configuration storage method JSON"Data/configuration storage method JSON" take cocos2d for iPhone + touchjson as an Example", I summarized how to use JSON as the configuration, but in fact, although the JSON syntax format is simple, and the use of the parsing library is also very simple, but because of this simplicity, some features are missing.
Redis supports LUA scripts from 2.6, similar to the functionality of transactions, where multiple Redis commands can be executed by the Lua script atom. Redis provides the eval and Evalsha commands to execute LUA scripts.Create and modify LUA's bad environmentRedis has a LUA environment embedded in the server, and a se
Lua provides advanced require functions to load the Runtime Library. Roughly speaking, require and dofile perform the same function, but there are two differences:
1.Require searches for directories to load files.
2.Require checks whether the file has been loaded to avoid repeated loading of the same file..
Because of the above features, require is a better function for loading databases in Lua.
The path us
In the first two articles, the use of C + + calling Lua in VS2010 compiled lua5.1 source generation Lua.lib and VS projects has been described to ensure that the demo runs on vs. Here is a detailed introduction to the mutual invocation and rationale between C + + and Lua.The direct call of C + + and Lua actually passes the data through a stack structure, the top index value of the stack structure is-1, the
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.