Original link: http://sunxiunan.com/?p=1498
You could download the project from http://groups.google.com/group/lua5/web/luautil.rar
At first, create a windows dll application. The IDE I used is VC2008.
I suggest you download and install the "Lua for windows
"
from luaforge.net, it contains most useful packages for Lua windows
development. You could copy "include" and "lib" directory under the
installation directory to your project.
In the beginning, you should include Lua header files.
Please note, you should use extern "C"
to declare the header for Lua. In linker’s input, set the lua51.lib.
The project should have a function like luaopen_xxx (in my code, it
is luaopen_luautil), and have strings=>functions map structure like
"lua_util". Then you could call your extension like require "luautil".
The L_MSleep will call windows’ api Sleep().
Another function L_NewTable will generate a complex table for Lua
script. It will call lua_settable() and lua_setfield() function to
manipulate the table in Lua. lua_pushstring() and lua_pushnumber()
could push string type and number type data to Lua. You could find the
document about these functions in Lua 5.1 manual.
The table that Lua get will like:
local table1 = {
userName1 = "hahaha",
serialNumber1 = "1234613423",
tbl = {userName2 = "wwwww", serialNumber2 = "asdfasdadf", "5566", "wowowo"}}
After you build the project, copy the dll to lua installation folder "lua\5.1\clibs".
In the end, we could test the extension like:
require "luautil"
local newtable =luautil.newtable()
for k, v in pairs(newtable) do
print(k, v)
if type(v) == "table" then
for k2, v2 in pairs(v) do
print("–", k2, v2)
end
end
end
– sleep 5 seconds.
luautil.msleep(5000)
分享到:
- 2009-11-24 11:00
- 浏览 1141
- 评论(0)
- 论坛回复 / 浏览 (0 / 2435)
- 查看更多
相关推荐
"STEP-BY-STEP--LUA.zip_lua_lua脚本_step by step" 这个标题表明,这是一个关于Lua脚本语言逐步学习的压缩包资源。它可能包含了逐步学习教程,帮助用户从基础到进阶掌握Lua编程。 **描述分析:** "Lua脚本语方学习...
lua for windows其实是一整套Lua的开发环境.Lua for Windows 为 Windows 系统下提供了 Lua 脚本语言的开发和运行环境。Lua 是一个小巧的脚本语言。作者是巴西人。该语言的设计目的是为了嵌入应用程序中,从而为应用...
Lua for Windows is a 'batteries included environment' for the Lua scripting language on Windows. Lua for Windows (LfW) combines Lua binaries, Lua libraries with a Lua-capable editor in a single ...
In order to execute LUA scripts you have to load them first and call them afterwarts, this is done by respectivily calling the lua_load and the lua_call or lua_pcall function. The lua_load function ...
LUAC脚本是一种基于Lua语言的编译格式,它将Lua源代码编译成字节码,以便在 Lua 解释器上高效运行。LUAC(Lua Compiler)是Lua官方提供的编译器,它将源代码转换为这种优化的字节码,以提高执行速度。在游戏开发、...
C语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 LUA_CC语言头文件 ...
在IT领域,编程语言间的互操作性是至关重要的,尤其是当需要将低级语言(如C)的强大性能与高级语言...在提供的压缩文件`cluatest.rar`和`luac.rar`中,可能包含了具体的示例代码和实践教程,供你进一步学习和研究。
Visual Studio Extension for Lua is a free, open source plugin that turns Visual Studio into a Lua development environment. It is designed, developed, and supported by Microsoft and the community. The...
Lua is a small and simple language, partly because it does not try to do what C is already good for, such as sheer performance and interface with third-party software. Lua relies on C for these tasks...
1. **Lua API for C**: Lua提供了一套C语言的API,允许C代码与Lua环境进行交互。这包括创建和初始化Lua状态机,加载和执行脚本,以及在C和Lua之间传递数据。 2. **注册C函数到Lua**: 使用`lua_pushcclosure`和`lua_...
在Windows环境下,为了方便用户使用Lua,有两个重要的工具:LuaForWindows和MinGW。这个压缩包"LuaForWindows_v5.1.5-52及mingw"包含了这两个工具的5.1版本,是开发者在Windows上搭建Lua开发环境的基础。 1. **Lua...
在Linux底下,从C语言调用Lua代码的一个简单例子。
Lua源代码是文本形式的,易于阅读和编写,但为了保护代码不被轻易篡改或盗用,开发者通常会将Lua代码编译成字节码(.lua.c文件或.luac文件)。"LUAC"就是Lua的官方编译器,它将Lua源代码转换为字节码,以提高执行...
标题“lua and acl example”揭示了本主题是关于使用Lua脚本语言与Access Control Lists (ACL)相结合的一个示例。Lua是一种轻量级的、解释型的编程语言,常用于游戏开发、配置文件、服务器应用等领域。而ACL则通常...
5. **C API**:Lua提供了C API,允许开发者用C/C++编写扩展模块,以增加新的功能或提高性能。 **LuaForWindows** LuaForWindows是一个专门针对Windows平台的Lua环境,它通常包含以下组件: 1. **集成开发环境...
For example, you should be able to extract a Unicode string from a database and pass it to a Unicode-aware graphics library. But see the sections below on pattern matching and string equality. ...
Lua for Windows 5.1.4-46 是一个针对Windows平台优化的Lua解释器版本。Lua是一种轻量级的脚本语言,广泛应用于游戏开发、嵌入式系统、服务器配置等多个领域。这个版本的发布是为了让Windows用户能够更方便地在他们...