summaryrefslogtreecommitdiffstats
path: root/src/scripting/luascript.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/scripting/luascript.h')
-rw-r--r--src/scripting/luascript.h40
1 files changed, 27 insertions, 13 deletions
diff --git a/src/scripting/luascript.h b/src/scripting/luascript.h
index e26fd9e..57b8dc1 100644
--- a/src/scripting/luascript.h
+++ b/src/scripting/luascript.h
@@ -44,8 +44,12 @@ class LuaScript : public Script
void load(const char *prog, const char *name);
+ Thread *newThread();
+
void prepare(Ref function);
+ void prepareResume(Thread *thread);
+
void push(int);
void push(const std::string &);
@@ -56,25 +60,24 @@ class LuaScript : public Script
int execute();
+ bool resume();
+
void assignCallback(Ref &function);
- static void getQuestCallback(Character *, const std::string &,
- const std::string &, Script *);
+ static void getQuestCallback(Character *,
+ const std::string &value,
+ Script *);
- static void getPostCallback(Character *, const std::string &,
- const std::string &, Script *);
+ static void getPostCallback(Character *,
+ const std::string &sender,
+ const std::string &letter,
+ Script *);
void processDeathEvent(Being *thing);
void processRemoveEvent(Thing *thing);
- static void setQuestReplyCallback(Script *script)
- { script->assignCallback(mQuestReplyCallback); }
-
- static void setPostReplyCallback(Script *script)
- { script->assignCallback(mPostReplyCallback); }
-
static void setDeathNotificationCallback(Script *script)
{ script->assignCallback(mDeathNotificationCallback); }
@@ -84,13 +87,24 @@ class LuaScript : public Script
static const char registryKey;
private:
- lua_State *mState;
+ class LuaThread : public Thread
+ {
+ public:
+ LuaThread(LuaScript *script);
+ ~LuaThread();
+
+ lua_State *mState;
+ int mRef;
+ };
+
+ lua_State *mRootState;
+ lua_State *mCurrentState;
int nbArgs;
- static Ref mQuestReplyCallback;
- static Ref mPostReplyCallback;
static Ref mDeathNotificationCallback;
static Ref mRemoveNotificationCallback;
+
+ friend class LuaThread;
};
static Script *LuaFactory()