Http://www.cnblogs.com/clever101/archive/2010/04/14/1712207.htmlZhu JinchanSource: http://www.cnblogs.com/clever101/The LUA language is widely used in the gaming world for its excellent extensibility, simplicity, efficiency, and platform independence. It took some time today to learn how VC and LUA mixed development, to write a small routine, and to share this experience with you.First download the latest v
This tutorial will explain how to call C + + functions in Lua.
In Lua, it is simpler to call C + + functions, and this article will demonstrate a concrete approach with two examples: one for averages and the other for printing parameter information for LUA functions.
Finally, this article describes how to define these two functions as a module so that the globa
1. Introduction
Let's talk about how to define a function by Lua and then call it in C or C ++. we will not discuss the C ++ object at the moment. We will only discuss the use of function parameters, return values, and global variables.
2.
Here, we first define a simple add (), X, and y in e12.lua as the two parameters of addition. Return returns the result after addition.
Example: e12.
Make Lua object-orientedLUA does not natively support object-oriented features, but since Lua is a prototype-based (prototype) language, there are certain ways to implement object-oriented features, and there are many ways to implement it, summarizing my recent use of LUA to implement object-oriented features, The main can be divided into the following two differ
Tags: Lua cocos2dx
[Nagging]
When using Lua, The cocos2d-x provides us withClass (classname, super)This function.
It allows us to easily define a class, or inherit a class from the cocos2d-x.
PS: Class () is the cocos2d-x for our encapsulated function, itself Lua does not have this function.
[Class]
Class FunctionsIs defined in "cocos2d-x-3.2/Cocos/scripting/
This is a creation in
Article, where the information may have evolved or changed.
There is a need to use the go language to implement some basic modules, using LUA to implement basic logic, so there is the need to invoke the Go function in Lua.
There is very little data on go, but the go can embed the C language, making this implementation feasible. Finally, the full userdata in
Recently doing something strange that requires the Java application to be able to accept user-submitted scripts and execute, the network part I chose NANOHTTPD to provide basic HTTP server support, and in Java can host many scripting languages for a long time, such as Rhino, Jython and JRuby, but they are too large, and it is difficult to implement a sandbox protection server environment. In the end I looked at Lua, the language known as the binder. T
Source: http://www.cppblog.com/Leaf/archive/2009/05/16/83145.html
It is said that the author of this article is ogdev's hack master.
Use examples to learn about Lua (1) ---- Hello World
1. PrefaceThe scripting language is indispensable in the game. Lua is a very closely-integrated scripting language with C/C ++, with extremely high efficiency.Generally, C ++ is used to write the time requirements,
All articles on this site areLi huaming himiOriginal, reprinted must be explicitly noted:Reprinted from[Heimi gamedev block]Link: http://www.himigame.com/iphone-cocos2dx/681.html☞Click to subscribe☜The latest developments in this blog! Notify you of the latest blog in time!
For gaming companies, it is also common to use game scripts such as Lua and python for development. However, many shoes are not very familiar with the concept of scripts, this art
Lua common data structure and lua Data Structure
The table in Lua is not a simple data structure. It can be used as the basis of other data structures. Such as arrays, records, linear tables, queues, and sets, which can be expressed by tables in Lua.
I. Array
In lua, you can
[Nagging]
First, you have learned at least one host language (C ++, Java, etc.) by default, and then turn to Lua.
Because 51cto does not have code highlighting for Lua, I have to use it to make the Code look colorful. 650) This. width = 650; "src =" http://img.baidu.com/hi/face/ I _f32.gif "alt =" I _f32.gif "/>
This section only introduces the basic simple Syntax of L
It is easy to register a C + + enumeration in LUA code, just like registering a global variable. We use the enumeration name as a namespace to avoid conflicting enumeration registrations. The registered enumeration is stored in the Global environment (the thread environment).When an enumeration is accessed in Lua code, the corresponding value is accessed by name.Sample_9.cpp C + + code is as follows:Enum re
ObjectiveLUA has 6 data types, nil (empty), Boolean (Boolean), number (numeric), string (character), table (table), function (functions)You can use the type function in Lua to return a value or the type to which a variable belongs, such as:Print (Type ("Helle World"))-->output:stringprint (type (print))-->output:functionprint (type (TRUE))-- Output:boolean1. Nil (empty)Lua uses nil to denote an "invalid val
Requirement
Affected by wow, Lua is increasingly used in games. Scripts are used in games to plan and compile game rules. In practical use,We will bind many host language functions to the Lua script so that the script can control the program running more. For example, we can bind functions such as npcdialog.In Lua, you can control the NPC dialog box displayed in
1. IntroductionThis section describes some Lua APIs for Stack operations and data type determination. You can use these functions to obtain the variable values in the script.
2. StepsCompile the test01.lua script, create the console C ++ program in vs2003, correctly configure the program, run the result, modify the script test02.lua, and view the execution result
-- Example 11 -- numbers.
-- Multiple assignment showing different number formats.-- Two dots (..) are used to concatenate strings (or a-- string and a number).a,b,c,d,e = 1, 1.123, 1E9, -123, .0008print("a="..a, "b="..b, "c="..c, "d="..d, "e="..e) -------- Output ------a=1 b=1.123 c=1000000000 d=-123 e=0.0008
-- Example 12 -- more output.
-- More writing output.print "Hello from Lua!"print("Hello from Lua!
What is metatableMetaTable is an important concept in Lua, and each table can be combined with metatable to change the behavior of the corresponding table.Metatables Example-- declare a normal relational variable lo_table =-- declare empty meta table variable lo_meta_table = {}-- Set the meta-table variable for the relationship variable T setmetatable-- get a meta-table variable for a relational variable getmetatable(lo _table)The upper code can al
With Cocos2dx-lua's classmates, we all know the callback function , in Lua , we can pass a method as a parameter to another method and then call it in the method . But we often have to write C + + code and then turn it into Lua, so how does C + + receive the Lua method and make the call . Here's a look at the implementation of the most recently written download l
Continue to the content, in C using LUA, this online resources are more, but I also mention Ha, after all, after all, it is very good.Environment: lua5.1,vs2013 Chinese version----------------------------------------------------, configure Lua in C + +----------------------------------------1. Download the LUA source code: http://www.lua.org/download.htmlIt's OK.
See "How quick-cocos2d-x 3.3 binds custom classes to LUA II" in the new project, we have completed the environment required for binding in our new project, and the next most critical step. Binds custom C + + classes to Lua. In fact, in order to facilitate our response to different platforms, the engine has helped us create projects of different platforms. In order to edit the code conveniently, I opened 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.