diff options
Diffstat (limited to 'src/scripting/script.h')
-rw-r--r-- | src/scripting/script.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/scripting/script.h b/src/scripting/script.h index bd143114..b475a0f0 100644 --- a/src/scripting/script.h +++ b/src/scripting/script.h @@ -21,11 +21,12 @@ #ifndef SCRIPTING_SCRIPT_H #define SCRIPTING_SCRIPT_H -#include <string> - -#include "game-server/character.h" +#include "common/inventorydata.h" #include "game-server/eventlistener.h" +#include <list> +#include <string> + class MapComposite; class Thing; @@ -35,7 +36,9 @@ class Thing; class Script { public: - + /** + * Defines a function that creates a Script instance. + */ typedef Script *(*Factory)(); /** @@ -48,6 +51,15 @@ class Script */ static Script *create(const std::string &engine); + /** + * A reference to a script object. It's just an integer, but the + * typedef makes the purpose of the variable clear. + * + * Variables of this type should be initialized to Script::NoRef. + */ + typedef int Ref; + static Ref NoRef; + Script(); virtual ~Script() {} @@ -81,6 +93,12 @@ class Script virtual void update(); /** + * Prepares a call to the referenced function. + * Only one function can be prepared at once. + */ + virtual void prepare(Ref function) = 0; + + /** * Prepares a call to the given function. * Only one function can be prepared at once. */ @@ -117,6 +135,13 @@ class Script virtual int execute() = 0; /** + * Assigns the current callback to the given \a function. + * + * Where the callback exactly comes from is up to the script engine. + */ + virtual void assignCallback(Ref &function) = 0; + + /** * Sets associated map. */ void setMap(MapComposite *m) |