00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef LUASCRIPT_HPP_INCLUDED
00023 #define LUASCRIPT_HPP_INCLUDED
00024
00025 extern "C" {
00026 #include <lualib.h>
00027 #include <lauxlib.h>
00028 }
00029
00030 #include "scripting/script.hpp"
00031
00035 class LuaScript: public Script
00036 {
00037 public:
00042 LuaScript();
00043
00047 ~LuaScript();
00048
00049 void load(const char *);
00050
00051 void prepare(const std::string &);
00052
00053 void push(int);
00054
00055 void push(const std::string &);
00056
00057 void push(Thing *);
00058
00059 int execute();
00060
00061 static void getQuestCallback(Character *, const std::string &,
00062 const std::string &, void *);
00063
00064 static void getPostCallback(Character *, const std::string &,
00065 const std::string &, void *);
00066
00067 void processDeathEvent(Being* thing);
00068
00069 void processRemoveEvent(Thing* thing);
00070
00071 private:
00072
00073 lua_State *mState;
00074 int nbArgs;
00075 std::string mCurFunction;
00076 };
00077
00078 static char const registryKey = 0;
00079
00080 static Script *LuaFactory()
00081 {
00082 return new LuaScript();
00083 }
00084
00085 struct LuaRegister
00086 {
00087 LuaRegister() { Script::registerEngine("lua", LuaFactory); }
00088 };
00089
00090 static LuaRegister dummy;
00091
00092 #endif // LUASCRIPT_HPP_INCLUDED