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