1
0

Working on a new plugin design with Lua. While retaining backwards compatibility of course...

In this new design a plugin consists of a folder with Lua files, this should enable plugin developers to keep things separate and have more overview.

git-svn-id: http://mc-server.googlecode.com/svn/trunk@172 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth
2012-01-26 20:39:46 +00:00
parent d8fa9c15d7
commit 4e34e438f1
12 changed files with 544 additions and 49 deletions

View File

@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 01/22/12 20:44:42.
** Generated automatically by tolua++-1.0.92 on 01/26/12 18:52:03.
*/
#ifndef __cplusplus
@@ -30,6 +30,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S);
#include "cPlayer.h"
#include "cPluginManager.h"
#include "cPlugin.h"
#include "cPlugin_NewLua.h"
#include "cPlugin_Lua.h"
#include "cServer.h"
#include "cWorld.h"
@@ -162,50 +163,52 @@ static void tolua_reg_types (lua_State* tolua_S)
tolua_usertype(tolua_S,"cPlugin");
tolua_usertype(tolua_S,"cStringMap");
tolua_usertype(tolua_S,"Json::Value");
tolua_usertype(tolua_S,"cServer");
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"cRoot");
tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"Lua__cPacket_BlockDig");
tolua_usertype(tolua_S,"cPlugin::CommandStruct");
tolua_usertype(tolua_S,"cPickup");
tolua_usertype(tolua_S,"cRecipeChecker");
tolua_usertype(tolua_S,"cWorld");
tolua_usertype(tolua_S,"cPacket_Login");
tolua_usertype(tolua_S,"cClientHandle");
tolua_usertype(tolua_S,"Lua__cPacket_BlockDig");
tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cFurnaceRecipe");
tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cChatColor");
tolua_usertype(tolua_S,"cMCLogger");
tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cPacket_PickupSpawn");
tolua_usertype(tolua_S,"Lua__cWebPlugin");
tolua_usertype(tolua_S,"Lua__cPawn");
tolua_usertype(tolua_S,"cGroup");
tolua_usertype(tolua_S,"cMCLogger");
tolua_usertype(tolua_S,"cItem");
tolua_usertype(tolua_S,"Vector3f");
tolua_usertype(tolua_S,"cPlugin_Lua");
tolua_usertype(tolua_S,"cTracer");
tolua_usertype(tolua_S,"cCuboid");
tolua_usertype(tolua_S,"Lua__cPlayer");
tolua_usertype(tolua_S,"cPacket");
tolua_usertype(tolua_S,"cPacket_BlockDig");
tolua_usertype(tolua_S,"cWebAdmin");
tolua_usertype(tolua_S,"Vector3i");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"Lua__cTCPLink");
tolua_usertype(tolua_S,"Lua__cPlugin");
tolua_usertype(tolua_S,"cBlockEntity");
tolua_usertype(tolua_S,"cTCPLink");
tolua_usertype(tolua_S,"cRecipeChecker");
tolua_usertype(tolua_S,"Lua__cPlugin");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cPacket_BlockPlace");
tolua_usertype(tolua_S,"cLadder");
tolua_usertype(tolua_S,"cGroupManager");
tolua_usertype(tolua_S,"cWorld");
tolua_usertype(tolua_S,"cIniFile");
tolua_usertype(tolua_S,"cPluginManager");
tolua_usertype(tolua_S,"Lua__cPlugin_NewLua");
tolua_usertype(tolua_S,"cIniFile");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"HTTPRequest");
tolua_usertype(tolua_S,"cPawn");
tolua_usertype(tolua_S,"cPlayer");
tolua_usertype(tolua_S,"cTorch");
tolua_usertype(tolua_S,"Lua__cPickup");
tolua_usertype(tolua_S,"cEntity");
tolua_usertype(tolua_S,"cInventory");
tolua_usertype(tolua_S,"Lua__cEntity");
tolua_usertype(tolua_S,"cWebPlugin");
tolua_usertype(tolua_S,"cPlugin_NewLua");
tolua_usertype(tolua_S,"cServer");
tolua_usertype(tolua_S,"cStairs");
tolua_usertype(tolua_S,"Vector3d");
}
@@ -8008,6 +8011,295 @@ static int tolua_collect_Lua__cPlugin (lua_State* tolua_S)
}
#endif
/* method: Initialize of class cPlugin_NewLua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_NewLua_Initialize00
static int tolua_AllToLua_cPlugin_NewLua_Initialize00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlugin_NewLua",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlugin_NewLua* self = (cPlugin_NewLua*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'Initialize'", NULL);
#endif
{
bool tolua_ret = (bool) self->Initialize();
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'Initialize'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
class Lua__cPlugin_NewLua : public cPlugin_NewLua, public ToluaBase {
public:
bool Initialize( void ) {
if (push_method("Initialize", tolua_AllToLua_cPlugin_NewLua_Initialize00)) {
ToluaBase::dbcall(lua_state, 1, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: Initialize();
};
};
void OnDisable( void ) {
if (push_method("OnDisable", tolua_AllToLua_cPlugin_OnDisable00)) {
ToluaBase::dbcall(lua_state, 1, 0);
} else {
return ( void ) cPlugin_NewLua:: OnDisable();
};
};
void Tick( float a_Dt) {
if (push_method("Tick", tolua_AllToLua_cPlugin_Tick00)) {
tolua_pushnumber(lua_state, (lua_Number)a_Dt);
ToluaBase::dbcall(lua_state, 2, 0);
} else {
return ( void ) cPlugin_NewLua:: Tick(a_Dt);
};
};
bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) {
if (push_method("OnCollectItem", tolua_AllToLua_cPlugin_OnCollectItem00)) {
tolua_pushusertype(lua_state, (void*)a_Pickup, "cPickup");
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 3, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnCollectItem(a_Pickup,a_Player);
};
};
bool OnDisconnect( std::string a_Reason, cPlayer* a_Player) {
if (push_method("OnDisconnect", tolua_AllToLua_cPlugin_OnDisconnect00)) {
tolua_pushcppstring(lua_state, (const char*)a_Reason);
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 3, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnDisconnect(a_Reason,a_Player);
};
};
bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) {
if (push_method("OnBlockPlace", tolua_AllToLua_cPlugin_OnBlockPlace00)) {
tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockPlace");
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 3, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnBlockPlace(a_PacketData,a_Player);
};
};
bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) {
if (push_method("OnBlockDig", tolua_AllToLua_cPlugin_OnBlockDig00)) {
tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_BlockDig");
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
tolua_pushusertype(lua_state, (void*)a_PickupItem, "cItem");
ToluaBase::dbcall(lua_state, 4, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnBlockDig(a_PacketData,a_Player,a_PickupItem);
};
};
bool OnChat( const char* a_Chat, cPlayer* a_Player) {
if (push_method("OnChat", tolua_AllToLua_cPlugin_OnChat00)) {
tolua_pushstring(lua_state, (const char*)a_Chat);
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 3, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnChat(a_Chat,a_Player);
};
};
bool OnLogin( cPacket_Login* a_PacketData) {
if (push_method("OnLogin", tolua_AllToLua_cPlugin_OnLogin00)) {
tolua_pushusertype(lua_state, (void*)a_PacketData, "cPacket_Login");
ToluaBase::dbcall(lua_state, 2, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnLogin(a_PacketData);
};
};
void OnPlayerSpawn( cPlayer* a_Player) {
if (push_method("OnPlayerSpawn", tolua_AllToLua_cPlugin_OnPlayerSpawn00)) {
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 2, 0);
} else {
return ( void ) cPlugin_NewLua:: OnPlayerSpawn(a_Player);
};
};
bool OnPlayerJoin( cPlayer* a_Player) {
if (push_method("OnPlayerJoin", tolua_AllToLua_cPlugin_OnPlayerJoin00)) {
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 2, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnPlayerJoin(a_Player);
};
};
void OnPlayerMove( cPlayer* a_Player) {
if (push_method("OnPlayerMove", tolua_AllToLua_cPlugin_OnPlayerMove00)) {
tolua_pushusertype(lua_state, (void*)a_Player, "cPlayer");
ToluaBase::dbcall(lua_state, 2, 0);
} else {
return ( void ) cPlugin_NewLua:: OnPlayerMove(a_Player);
};
};
void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) {
if (push_method("OnTakeDamage", tolua_AllToLua_cPlugin_OnTakeDamage00)) {
tolua_pushusertype(lua_state, (void*)a_Pawn, "cPawn");
tolua_pushusertype(lua_state, (void*)a_TakeDamageInfo, "TakeDamageInfo");
ToluaBase::dbcall(lua_state, 3, 0);
} else {
return ( void ) cPlugin_NewLua:: OnTakeDamage(a_Pawn,a_TakeDamageInfo);
};
};
bool OnKilled( cPawn* a_Killed, cEntity* a_Killer) {
if (push_method("OnKilled", tolua_AllToLua_cPlugin_OnKilled00)) {
tolua_pushusertype(lua_state, (void*)a_Killed, "cPawn");
tolua_pushusertype(lua_state, (void*)a_Killer, "cEntity");
ToluaBase::dbcall(lua_state, 3, 1);
bool tolua_ret = ( bool )tolua_toboolean(lua_state, -1, 0);
lua_pop(lua_state, 1);
return tolua_ret;
} else {
return ( bool ) cPlugin_NewLua:: OnKilled(a_Killed,a_Killer);
};
};
bool cPlugin_NewLua__Initialize( void ) {
return ( bool )cPlugin_NewLua::Initialize();
};
void cPlugin_NewLua__OnDisable( void ) {
return ( void )cPlugin_NewLua::OnDisable();
};
void cPlugin_NewLua__Tick( float a_Dt) {
return ( void )cPlugin_NewLua::Tick(a_Dt);
};
bool cPlugin_NewLua__OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player) {
return ( bool )cPlugin_NewLua::OnCollectItem(a_Pickup,a_Player);
};
bool cPlugin_NewLua__OnDisconnect( std::string a_Reason, cPlayer* a_Player) {
return ( bool )cPlugin_NewLua::OnDisconnect(a_Reason,a_Player);
};
bool cPlugin_NewLua__OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player) {
return ( bool )cPlugin_NewLua::OnBlockPlace(a_PacketData,a_Player);
};
bool cPlugin_NewLua__OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem) {
return ( bool )cPlugin_NewLua::OnBlockDig(a_PacketData,a_Player,a_PickupItem);
};
bool cPlugin_NewLua__OnChat( const char* a_Chat, cPlayer* a_Player) {
return ( bool )cPlugin_NewLua::OnChat(a_Chat,a_Player);
};
bool cPlugin_NewLua__OnLogin( cPacket_Login* a_PacketData) {
return ( bool )cPlugin_NewLua::OnLogin(a_PacketData);
};
void cPlugin_NewLua__OnPlayerSpawn( cPlayer* a_Player) {
return ( void )cPlugin_NewLua::OnPlayerSpawn(a_Player);
};
bool cPlugin_NewLua__OnPlayerJoin( cPlayer* a_Player) {
return ( bool )cPlugin_NewLua::OnPlayerJoin(a_Player);
};
void cPlugin_NewLua__OnPlayerMove( cPlayer* a_Player) {
return ( void )cPlugin_NewLua::OnPlayerMove(a_Player);
};
void cPlugin_NewLua__OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo) {
return ( void )cPlugin_NewLua::OnTakeDamage(a_Pawn,a_TakeDamageInfo);
};
bool cPlugin_NewLua__OnKilled( cPawn* a_Killed, cEntity* a_Killer) {
return ( bool )cPlugin_NewLua::OnKilled(a_Killed,a_Killer);
};
};
/* method: tolua__set_instance of class Lua__cPlugin_NewLua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_NewLua_tolua__set_instance00
static int tolua_AllToLua_Lua__cPlugin_NewLua_tolua__set_instance00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"Lua__cPlugin_NewLua",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,3,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
Lua__cPlugin_NewLua* self = (Lua__cPlugin_NewLua*) tolua_tousertype(tolua_S,1,0);
lua_State* L = tolua_S;
lua_Object lo = ((lua_Object) tolua_tovalue(tolua_S,2,0));
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'tolua__set_instance'", NULL);
#endif
{
self->tolua__set_instance(L,lo);
}
}
return 0;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'tolua__set_instance'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: cPlugin_NewLua__Initialize of class Lua__cPlugin_NewLua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_Lua__cPlugin_NewLua_cPlugin_NewLua__Initialize00
static int tolua_AllToLua_Lua__cPlugin_NewLua_cPlugin_NewLua__Initialize00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"Lua__cPlugin_NewLua",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
Lua__cPlugin_NewLua* self = (Lua__cPlugin_NewLua*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'cPlugin_NewLua__Initialize'", NULL);
#endif
{
bool tolua_ret = (bool) self->cPlugin_NewLua__Initialize();
tolua_pushboolean(tolua_S,(bool)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'cPlugin_NewLua__Initialize'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetFileName of class cPlugin_Lua */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlugin_Lua_GetFileName00
static int tolua_AllToLua_cPlugin_Lua_GetFileName00(lua_State* tolua_S)
@@ -16201,6 +16493,15 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,".call",tolua_AllToLua_Lua__cPlugin_new00_local);
tolua_function(tolua_S,"delete",tolua_AllToLua_Lua__cPlugin_delete00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cPlugin_NewLua","cPlugin_NewLua","cPlugin",NULL);
tolua_beginmodule(tolua_S,"cPlugin_NewLua");
tolua_function(tolua_S,"Initialize",tolua_AllToLua_cPlugin_NewLua_Initialize00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"Lua__cPlugin_NewLua","Lua__cPlugin_NewLua","cPlugin_NewLua",NULL);
tolua_beginmodule(tolua_S,"Lua__cPlugin_NewLua");
tolua_function(tolua_S,"tolua__set_instance",tolua_AllToLua_Lua__cPlugin_NewLua_tolua__set_instance00);
tolua_function(tolua_S,"cPlugin_NewLua__Initialize",tolua_AllToLua_Lua__cPlugin_NewLua_cPlugin_NewLua__Initialize00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cPlugin_Lua","cPlugin_Lua","",NULL);
tolua_beginmodule(tolua_S,"cPlugin_Lua");
tolua_function(tolua_S,"GetFileName",tolua_AllToLua_cPlugin_Lua_GetFileName00);