Script Class Reference

Abstract interface for calling functions written in an external language. More...

#include <script.hpp>

Inheritance diagram for Script:

LuaScript

List of all members.

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.
MapCompositegetMap () const
 Gets associated map.
EventListenergetScriptListener ()
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 Scriptcreate (const std::string &engine)
 Creates a new script context for a given engine.

Protected Attributes

std::string mScriptFile

Friends

struct ScriptEventDispatch


Detailed Description

Abstract interface for calling functions written in an external language.

Definition at line 35 of file script.hpp.


Member Function Documentation

void Script::loadNPC ( const std::string &  name,
int  id,
int  x,
int  y,
const char *  prog 
) [virtual]

Loads a chunk of text and considers it as an NPC handler.

This handler will later be used to create the given NPC.

Definition at line 87 of file script.cpp.

References execute(), load(), prepare(), and push().

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.

References execute(), and prepare().

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.

Returns:
the value returned by the script.

Implemented in LuaScript.

Referenced by loadNPC(), NPC::prompt(), NPC::select(), update(), NPC::update(), ItemClass::use(), and Character::useSpecial().


The documentation for this class was generated from the following files:

Generated on Sun Apr 26 17:30:46 2009 for TMW Server Collection by  doxygen 1.5.5