2012-01-26 12:39:46 -08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "cPlugin.h"
|
|
|
|
#include <string>
|
2012-01-27 15:47:32 -08:00
|
|
|
#include <list>
|
2012-01-26 12:39:46 -08:00
|
|
|
|
|
|
|
typedef struct lua_State lua_State;
|
2012-01-27 15:47:32 -08:00
|
|
|
class cWebPlugin_Lua;
|
2012-01-26 12:39:46 -08:00
|
|
|
|
2012-01-26 15:10:49 -08:00
|
|
|
class cPlugin_NewLua : public cPlugin //tolua_export
|
|
|
|
{ //tolua_export
|
|
|
|
public: //tolua_export
|
2012-01-26 12:39:46 -08:00
|
|
|
cPlugin_NewLua( const char* a_PluginName );
|
|
|
|
~cPlugin_NewLua();
|
|
|
|
|
2012-02-01 11:19:51 -08:00
|
|
|
virtual void OnDisable(); //tolua_export
|
|
|
|
virtual bool Initialize(); //tolua_export
|
|
|
|
|
|
|
|
virtual void Tick(float a_Dt); //tolua_export
|
|
|
|
|
|
|
|
//tolua_begin
|
|
|
|
virtual bool OnCollectItem( cPickup* a_Pickup, cPlayer* a_Player );
|
|
|
|
virtual bool OnDisconnect( std::string a_Reason, cPlayer* a_Player );
|
|
|
|
virtual bool OnBlockPlace( cPacket_BlockPlace* a_PacketData, cPlayer* a_Player );
|
|
|
|
virtual bool OnBlockDig( cPacket_BlockDig* a_PacketData, cPlayer* a_Player, cItem* a_PickupItem );
|
|
|
|
virtual bool OnChat( const char* a_Chat, cPlayer* a_Player );
|
|
|
|
virtual bool OnLogin( cPacket_Login* a_PacketData );
|
|
|
|
virtual void OnPlayerSpawn( cPlayer* a_Player );
|
|
|
|
virtual bool OnPlayerJoin( cPlayer* a_Player );
|
|
|
|
virtual void OnPlayerMove( cPlayer* a_Player );
|
|
|
|
virtual void OnTakeDamage( cPawn* a_Pawn, TakeDamageInfo* a_TakeDamageInfo );
|
|
|
|
virtual bool OnKilled( cPawn* a_Killed, cEntity* a_Killer );
|
|
|
|
//tolua_end
|
2012-01-26 12:39:46 -08:00
|
|
|
|
2012-01-27 15:47:32 -08:00
|
|
|
lua_State* GetLuaState() { return m_LuaState; }
|
|
|
|
|
|
|
|
cWebPlugin_Lua* CreateWebPlugin(lua_State* a_LuaState); //tolua_export
|
2012-01-26 12:39:46 -08:00
|
|
|
private:
|
2012-02-01 11:19:51 -08:00
|
|
|
bool PushFunction( const char* a_FunctionName, bool a_bLogError = true );
|
2012-01-26 15:10:49 -08:00
|
|
|
bool CallFunction( int a_NumArgs, int a_NumResults, const char* a_FunctionName ); // a_FunctionName is only used for error messages, nothing else
|
|
|
|
|
2012-01-27 15:47:32 -08:00
|
|
|
typedef std::list< cWebPlugin_Lua* > WebPluginList;
|
|
|
|
WebPluginList m_WebPlugins;
|
|
|
|
|
2012-02-22 07:15:44 -08:00
|
|
|
cCriticalSection m_CriticalSection;
|
|
|
|
|
2012-01-26 12:39:46 -08:00
|
|
|
std::string m_Directory;
|
|
|
|
lua_State* m_LuaState;
|
|
|
|
};//tolua_export
|