1
我的问题很简单:我在extendedgamefunctions
类的函数:
在标题:
#include "Gameitems.h"
extern "C" {
#include "lua.h"
#include "lualib.h"
#include "lauxlib.h"
};
extern std::vector<std::vector<Gameitems>> items;
class A
{
A();
~A();
public:
static void messagewindow(lua_State*);
};
而且代码:
Functions extfunctions;
A::A()
{}
A::~A()
{}
void A::messagewindow(lua_State *L)
{
string message =lua_tostring(L,0);
extfunctions.Messagewindow(message);
}
,我想绑定在另一个称为Gamefunctions
的功能中:
#include "Externedgamefunctions.h"
A egfunctions;
lua_State* L;
void Gamefunctions::luainit()
{
L = luaL_newstate();
/* load Lua base libraries */
luaL_openlibs(L);
lua_pushcfunction(L,&A::messagewindow);
lua_setglobal(L, "messagewindow");
}
直接
Error 5 error C2664: 'lua_pushcclosure' : cannot convert parameter 2 from 'void (__cdecl *)(lua_State *)' to 'lua_CFunction' C:\Users\Bady\Desktop\MY Game\basicconfig\BlueButterfly\BlueButterfly\Gamefunctions.cpp 170
我不想做一个加funtion到gamefunctions得到消息窗(除非我没有别的coises),因为我:
而是从另一大类funtion是静态的,我得到这个错误编写extendedgamefunctions不要创建一个无尽的stringmonster。
编辑: 差点忘了:Lua的5.2和C++ 11
谢谢。你是我的英雄:) – Bady
这是所有的错误信息:P 还应该注意的是,你返回的int是你推到堆栈的值的数量作为lua端函数的返回值。 – mtsvetkov
我明白了。是的,那就是我。我写了一个规模很大的代码,并搜索了几个小时拼写错误的“==”。但没有更大的错误。 – Bady