From ba5b55f3eba0aa3898c5fe42de9838b22473c24a Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 28 Feb 2012 23:37:23 +0100 Subject: Use callbacks for handling character death and respawn Rather than relying on the availability of global functions with certain predefined names, the Lua script now calls API functions to set which function should be called on these global events. This mechanism should make it easier to avoid name collisions in the global namespace, which is important now that there is only a single script state. For these global events this was not likely to become a problem, but this solution can also be used for callbacks on specific item or monster types, or even allow setting callbacks on certain instances. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira --- src/scripting/luascript.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/scripting/luascript.h') diff --git a/src/scripting/luascript.h b/src/scripting/luascript.h index 0d59703c..6f2bceee 100644 --- a/src/scripting/luascript.h +++ b/src/scripting/luascript.h @@ -44,6 +44,8 @@ class LuaScript : public Script void load(const char *prog, const char *name); + void prepare(Ref function); + void prepare(const std::string &); void push(int); @@ -56,6 +58,8 @@ class LuaScript : public Script int execute(); + void assignCallback(Ref &function); + static void getQuestCallback(Character *, const std::string &, const std::string &, void *); -- cgit v1.2.3-60-g2f50