• About
    • Resume
A Game Developer also plays some guitar

Tag Archives: Function

Lua相关问题整理(1)

November 7, 2010 10:17 pm / Benny Chen
  1. (Under Linux)cannot find ‘dlsym’ ‘dlopen’ ‘dlerror’ ‘dlclose’

    需要同时链接”dl“库

  2. (Under Linux)编译lua报错luaconf.h:275:31: error: readline/readline.h: No such file or directory

    需要下载并安装GNU Readline Library

  3. PANIC: unprotected error in call to Lua API (unable to get ModuleFileName)

    1: 不推荐的解决方式:将Project Properties->Configuration Properties->General下的Character Set从unicode改成multi-set;
    2: 彻底的解决方式,参考此链接:http://lua-users.org/lists/lua-l/2006-06/msg00427.html

  4. 如何将Lua文本文件转化为Lua块文件(chunk file)

    调用LuaAPI – lua_dump

    关于lua_dump: about lua_dump: Dumps a function as a binary chunk. Receives a Lua function on the top of the stack and produces a binary chunk that, if loaded again, results in a function equivalent to the one dumped. As it produces parts of the chunk, lua_dump calls function writer (see lua_Writer) with the given data to write them.

  5. 如何在C中调用Lua脚本层的库函数

    void BeginLuaLibCall( lua_State *L, const string &libName, const string &functionName )
    {
         lua_pushstring( L, libName.c_str() );
         lua_gettable( L, LUA_GLOBALSINDEX );
         lua_pushstring( L, functionName.c_str() );
         lua_gettable( L, -2 );
    }
    
    void EndLuaLibCall( lua_State *L )
    {
         lua_pop( L, -1 );
    }
    

    示例:调用table.getn(该函数用来获取一个table的size)

    // 利用上面的函数
    BeginLuaLibCall( L, "table", "getn" );
    // 假设你的脚本中有一个table变量myTable,获取它到栈顶
    lua_getglobal( L, "myTable" ); 
    // 执行table.getn( t )
    lua_call( L, 1, 1 ); 
    // 打印结果
    std::cout << lua_tonumber( L, -1 ) ) << std::endl;
    // 将结果弹出栈
    lua_pop( L, -1 );
    // 将名叫“table”的table弹出栈
    EndLuaLibCall( L);
    
Posted in: Game Programming, Lua / Tagged: chunk, dl, function, library, lua, readline

LinkedIn

Milan Petrovic

Categories

  • In My Life (25)
    • A Day in the Life (8)
    • English Learning (2)
    • Learn a Word (7)
    • Something In The Way (8)
  • Music Heaven (8)
    • Guitar (1)
    • In Concert (1)
    • Lyrics (3)
  • OK Computer (54)
    • 3D (3)
    • C++ (10)
    • Computer Graphics (15)
    • Game Programming (23)
    • iOS (6)
    • Linux (1)
    • Lua (9)
    • My Projects (3)
    • Some Experiences (9)
    • Talking in Code (2)
    • Unity (2)
  • Quotations (2)
  • Uncategorized (1)
  • Visca Barça (24)
    • FCB BJ (5)

Recent Posts

  • [译]优化你的手机游戏(没有延迟的,才是健康的)- 一篇给游戏美术设计师读的文章
  • 新浪微博API for MOAI
  • 稍后继续
  • Unity Developer ++
  • Another Thread @ Moai Forum
  • 1st Day of Golden Week
  • 为SyntaxHighlighter添加新语言
  • 基于Lua的State Pattern
  • Class Diagram of Pacman
  • 基于Moai的Pacman

Recent Comments

  • 约修亚_RK on 为SyntaxHighlighter添加新语言
  • 爱装的小男孩 on 小心DLL链接静态库时的内存错误
  • happyfire on Game Loop的几种实现方式
  • William on 新浪微博API for MOAI
  • Benny Chen on 新浪微博API for MOAI
  • your man on 新浪微博API for MOAI
  • 你家男人 on 稍后继续
  • 逍遥 on 关于对std::vector的遍历
  • papa on Unity Developer ++
  • T客网 ︱ Techpot » Blog Archive » iOS开发与OpenGL ES相关问题整理(1) on iOS开发与OpenGL ES相关问题整理(1)

Tags

2d 3D 3dsmax 3ds max air Apply architecture Asia tour barca Beijing bilbao binary search blocked bob boost bruce springsteen C++ capo CGContextDrawImage Champions League Change DLL DX10 eval exporter flash framework frustum culling game game engine iniesta ios linux lua Moai opengles pacman plug-in plugin 北京 导出插件 崩溃 巴萨 游戏引擎 踢球
© Copyright 2025 - A Game Developer
Infinity Theme by DesignCoral / WordPress