• Give an example to explain the table data structure in Lua


    In the text — single line comments starting with two horizontal lines, – [[add two [and] to indicate multi line comments –]].   Copy codeThe code is as follows: –Table = Lua’s unique data structure;—          They are associative arrays.–Similar to PHP arrays or JS objects,–They are hash lookup tables (dicts) and can also be […]

  • Examples are given to illustrate the use of meta tables and meta methods in Lua


    The meta table of table provides a mechanism to redefine some operations of table.After that, we will see how the meta table supports the prototype behavior similar to JS.   Copy codeThe code is as follows: f1 = {a = 1, b = 2}   — Represents a fraction A / b f2 = {a […]

  • Some basics of using modules in Lua


    –Two horizontal lines start a single line of comments, – [[plus two [and] indicates multi line comments –]].   Copy codeThe code is as follows: –Suppose the contents of the file mod.lua are: local M = {}   local function sayMyName()   print(‘Hrunkner’) end function M.sayHello()   print(‘Why hello there’)   sayMyName() end return M […]

  • Delve into analytical expressions in Lua


    Use a pattern This example shows a program for establishing and using patterns. It is very simple but complete:   Copy codeThe code is as follows: local lpeg = require “lpeg”   — matches a word followed by end-of-string p = lpeg.R”az”^1 * -1 print(p:match(“hello”))        –> 6 print(lpeg.match(p, “hello”))  –> 6 print(p:match(“1 hello”))      –> nil […]

  • Methods of using Lua to extend C + + programs


    introduce If users can modify the behavior of the application itself through some scripting languages, many applications can become more suitable for users. Some commercial applications provide such convenience. For example, VBA script programming for Microsoft office or used in video game world of WarcraftLua。 Scripting language takes the application as a platform to provide […]

  • Tutorial on installing Lua on Mac OS


      Lua is a lightweightprograming language, it is widely used in game development. In this article, we will introduce you to install and use the latest version of lua 5.2.1 on Mac OS X. If rudix has been installed on your system, just execute sudo rudix install Lua. Otherwise, rudix provides some independent software packages […]

  • Installation and environment configuration of lua under Windows


    Environment: luafor windows (LFW)Home page: http://luaforwindows.luaforge.net/ Lua for windows is actually a complete set of lua development environment, including:Lua interpreterLua reference manualQuick Lua TourExamples (Lua example)Libraries with documentationScite (a great multi-purpose editor with special settings for Lua) Other details can be found on luaforge’s home page. This environment is recommended because it integrates all the […]

  • Lua scripting language basic syntax quick start tutorial


    LuaThe syntax is somewhat similar to and different from C language. Write a sentence and learn to smile ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 […]

  • Building an event distribution system by analyzing the best practices of lua observer model


    catalogue 1、 Foreword 2、 Observer mode 3、 Event distribution system 4、 Use the event distribution system to solve the problem 5、 Register listening event interface 6、 Unregister event listening interface 7、 Event dispatch interface 8、 More 1、 Foreword Imagine such a problem. When an event occurs, for example, in the game, module a modifies the […]

  • Example of calling Lua configuration file and response function in C++


    Lua is a scripting language. Its biggest advantage is that it is light and convenient without compiling. When the C framework is written, the function can be changed as long as the corresponding processing of lua is changed, and there is no need to recompile. The following is an example program for calling Lua resource […]

  • Example of calling C++ function in Lua


    Of course, Lua can also call functions defined in C. An example of an average, explain it.   The C + + function average () given below demonstrates how to accept multiple parameters and return more than one value.1.lua_ The gettop function returns the index value of the top of the stack. Because the stack is […]

  • Research on the usage of lua function


    stayLua basic grammar quick startIt involvesfunctionBut it’s just an ordinary application. I haven’t studied it deeply. If there are still many functions, I’ll do a special study~     1、 Usage of functions and variables The function is defined with the keyword function. Then add the function name and variable. Note that there is no […]