#include <script.hpp>
Public Types | |
typedef Script *(* | Factory )() |
Public Member Functions | |
Script () | |
Constructor. | |
virtual | ~Script () |
Destructor. | |
virtual void | load (const char *)=0 |
Loads a chunk of text into script context and executes its global statements. | |
virtual bool | loadFile (const std::string &) |
Loads a text file into script context and executes its global statements. | |
virtual void | loadNPC (const std::string &name, int id, int x, int y, const char *) |
Loads a chunk of text and considers it as an NPC handler. | |
virtual void | update () |
Called every tick for the script to manage its data. | |
virtual void | prepare (const std::string &name)=0 |
Prepares a call to the given function. | |
virtual void | push (int)=0 |
Pushes an integer argument for the function being prepared. | |
virtual void | push (const std::string &)=0 |
Pushes a string argument for the function being prepared. | |
virtual void | push (Thing *)=0 |
Pushes a pointer argument to a game entity. | |
virtual int | execute ()=0 |
Executes the function being prepared. | |
void | setMap (MapComposite *m) |
Sets associated map. | |
MapComposite * | getMap () const |
Gets associated map. | |
EventListener * | getScriptListener () |
virtual void | processDeathEvent (Being *thing)=0 |
virtual void | processRemoveEvent (Thing *thing)=0 |
Static Public Member Functions | |
static void | registerEngine (const std::string &, Factory) |
Registers a new scripting engine. | |
static Script * | create (const std::string &engine) |
Creates a new script context for a given engine. | |
Protected Attributes | |
std::string | mScriptFile |
Friends | |
struct | ScriptEventDispatch |
Definition at line 35 of file script.hpp.
void Script::loadNPC | ( | const std::string & | name, | |
int | id, | |||
int | x, | |||
int | y, | |||
const char * | prog | |||
) | [virtual] |
void Script::update | ( | ) | [virtual] |
Called every tick for the script to manage its data.
Calls the "update" function of the script by default.
Definition at line 66 of file script.cpp.
virtual void Script::prepare | ( | const std::string & | name | ) | [pure virtual] |
Prepares a call to the given function.
Only one function can be prepared at once.
Implemented in LuaScript.
Referenced by loadNPC(), NPC::prompt(), NPC::select(), update(), NPC::update(), ItemClass::use(), and Character::useSpecial().
virtual void Script::push | ( | Thing * | ) | [pure virtual] |
Pushes a pointer argument to a game entity.
The interface can pass the pointer as an opaque value to the scripting engine, if needed. This value will usually be passed by the script to some callback functions.
Implemented in LuaScript.
virtual int Script::execute | ( | ) | [pure virtual] |
Executes the function being prepared.
Implemented in LuaScript.
Referenced by loadNPC(), NPC::prompt(), NPC::select(), update(), NPC::update(), ItemClass::use(), and Character::useSpecial().