add lua functions to support packet manipulation/send

This commit is contained in:
Andre (Notebook) 2012-01-13 09:19:33 +08:00 committed by Eduardo Bart
parent 8cace32ce7
commit 8f466b432c
2 changed files with 17 additions and 1 deletions

View File

@ -25,8 +25,11 @@
#include "declarations.h"
#include "networkexception.h"
#include <framework/luascript/luaobject.h>
class OutputMessage
typedef std::shared_ptr<OutputMessage> OutputMessagePtr;
class OutputMessage : public LuaObject
{
public:
enum {

View File

@ -89,6 +89,18 @@ void OTClient::registerLuaFunctions()
g_lua.registerClass<ProtocolGame, Protocol>();
g_lua.registerClass<OutputMessage>();
g_lua.bindClassStaticFunction<OutputMessage>("new", []{ return OutputMessagePtr(new OutputMessage); });
g_lua.bindClassMemberFunction<OutputMessage>("reset", &OutputMessage::reset);
g_lua.bindClassMemberFunction<OutputMessage>("addU8", &OutputMessage::addU8);
g_lua.bindClassMemberFunction<OutputMessage>("addU16", &OutputMessage::addU16);
g_lua.bindClassMemberFunction<OutputMessage>("addU32", &OutputMessage::addU32);
g_lua.bindClassMemberFunction<OutputMessage>("addU64", &OutputMessage::addU64);
g_lua.bindClassMemberFunction<OutputMessage>("addString", (void(OutputMessage::*)(const std::string&))&OutputMessage::addString);
g_lua.registerClass<Protocol>();
g_lua.bindClassStaticFunction<Protocol>("send", [](const ProtocolPtr proto, OutputMessagePtr msg) { proto->send(*msg.get()); });
g_lua.registerClass<Thing>();
g_lua.bindClassMemberFunction<Thing>("setId", &Thing::setId);
g_lua.bindClassMemberFunction<Thing>("setPos", &Thing::setPos);
@ -202,6 +214,7 @@ void OTClient::registerLuaFunctions()
g_lua.bindClassStaticFunction<Game>("talkPrivate", std::bind(&Game::talkPrivate, &g_game, _1, _2, _3));
g_lua.bindClassStaticFunction<Game>("getLocalPlayer", std::bind(&Game::getLocalPlayer, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolVersion", std::bind(&Game::getProtocolVersion, &g_game));
g_lua.bindClassStaticFunction<Game>("getProtocolGame", std::bind(&Game::getProtocolGame, &g_game));
g_lua.bindClassStaticFunction<Game>("setSelectedThing", std::bind(&Game::setSelectedThing, &g_game, _1));
g_lua.bindClassStaticFunction<Game>("getSelectedThing", std::bind(&Game::getSelectedThing, &g_game));