Lua Study Steps 1 run lua script file
来源:互联网 发布:网络购物投诉电话 编辑:程序博客网 时间:2024/06/07 05:02
Lua version 5.1
Lua是一个被设计成用于扩展C/C++编程的轻量级脚本语言.
1. http://www.lua.org/home.html download
http://luaforge.net/frs/?group_id=110 binaries
Add include(source file) directory and library(*.dll and *.lib) directory in VC.
Look luavs.bat file for install, you can get luaXX.dll/XX.lib and lua.exe luac.exe.
Add the path to environment variables that you can run lua any path
2. first program
lua_open()返回一个指向Lua解释器的一个指针。
luaL_openlibs()用于装载Lua库,它提供了一些简单的函数,如:print。
通过调用luaL_dofile()执行脚本。它的作用是读取并解释脚本。
最后,通过lua_close()函数关闭Lua。
In Visual C++ you’ll need to follow these steps:
Create a new empty Win32 Console Application Project.
如果你直接使用C而不是C++,将文件名改为luatest.c,然后将extern "C"删除。
put *.lua to your *.cpp path or you need location absolute path for *.lua file
#include//for _T macro#include #include #include using namespace std;#include "cpp_utils.h"//for GetModuleFileName use#include #pragma comment( lib ,"shlwapi.lib")//=========lua partextern "C"{#include #include #include }//load lib#pragma comment( lib ,"lua51.lib")//=========lua part endint main(){/* the Lua interpreter */lua_State* L;// /* initialize Lua */ L = lua_open();/* load Lua base libraries */luaL_openlibs(L);/*location app path */TCHAR path[MAX_PATH];GetModuleFileName(NULL, path, MAX_PATH);tstring str = path;str = str.substr(0, str.rfind( _T("//") ) );str += _T("//hello.lua");if ( FALSE == PathFileExists( str.c_str() ) ){cout<<"False";}string stra = widen2narrow(str);/* run the script */luaL_dofile(L, stra.c_str());/* cleanup Lua */ lua_close(L);system("pause");return 0;}
- Lua Study Steps 1 run lua script file
- Lua Self-study Log
- Run Python Script File
- Redis Lua Script Practice
- lua study & c与lua相互调用
- study lua step by step
- 0.windbg script-$<, $><, $$<, $$><, $$>a< (Run Script File)
- Beginning Lua Programming - First steps(第一步)
- Quest 3d中Lua script中常用方法1
- lua study -- how to call lua function use C language
- LUA
- Lua
- LUA
- lua
- Lua
- lua
- lua
- lua
- 什么是JTAG
- dom4j写文件时中文编码问题
- MSN登陆后死机的解决方案
- 答辩结束了
- ORA_01031:insufficient privieges conn / as sysdba
- Lua Study Steps 1 run lua script file
- rcp中透视图切换
- SQL操作全集
- Flash CS3 ActionScript 3.0入门
- 构造使用IN子句的动态Transact-SQL方法进行编号查询
- windows 2000时间同步
- 选建材、装饰上襄樊家居生活网
- Java正则表达式入门
- 酷睿e4500、2G内存、250G硬盘、15M服务器租用800元