diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-02-28 23:37:23 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-03-02 18:12:20 +0100 |
commit | ba5b55f3eba0aa3898c5fe42de9838b22473c24a (patch) | |
tree | 465e70d3bc4671b75f1af763d866eafa459f5d6f /src/scripting/luascript.h | |
parent | 05bb880a3b0ebe401bac83b7a2400aa315161f9c (diff) | |
download | manaserv-ba5b55f3eba0aa3898c5fe42de9838b22473c24a.tar.gz manaserv-ba5b55f3eba0aa3898c5fe42de9838b22473c24a.tar.bz2 manaserv-ba5b55f3eba0aa3898c5fe42de9838b22473c24a.tar.xz manaserv-ba5b55f3eba0aa3898c5fe42de9838b22473c24a.zip |
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
Diffstat (limited to 'src/scripting/luascript.h')
-rw-r--r-- | src/scripting/luascript.h | 4 |
1 files changed, 4 insertions, 0 deletions
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 *); |