试图调用函数但没有任何反应

时间:2015-10-31 17:25:01

标签: c++ lua

我似乎无法弄明白,我在课堂上收到的例子与我在网上看到的Lua示例有很大不同。

我从类中复制了这段代码并将其添加到我的cpp文件中:

#include "InputManager.h"
#include <iostream>
#include <string>

InputManager* InputManager::instance = NULL;

int LuaExample_OutputInt(lua_State *L) {
    int argc = lua_gettop(L);

    if (argc == 1) {
        const lua_Integer value = lua_tointeger(L, 1);
        std::cout << "Value: " << value << std::endl;
    }
    return 1;
};
REGISTER_LUA_FUNCTION(LuaExample, OutputInt)  

void InputManager::update() {

    std::string command;

    std::cout << "Enter LUA command:" << std::endl;
    std::getline(std::cin, command);

    LuaState::getLuaState()->executeLuaString(command.c_str());
}

程序编译没有问题并且没有显示错误,但程序在我输入值后才结束,它从不进入LuaExample_OutputInt部分。我做错了什么?

0 个答案:

没有答案
相关问题