BS_NMSP::Machine Class Reference

Facade class for controlling the system. More...

#include <bsMachine.h>

List of all members.

Public Member Functions

 Machine ()
 Constructor.
 ~Machine ()
 Destructor.
const LoggetLog () const
 Get the bulletscript log.
int registerGlobalVariable (const String &name, bool readOnly, bstype initialValue)
 Register a global variable, for use in script.
void setGlobalVariableValue (const String &name, bstype value)
 Set the named global variable.
int compileScript (const uint8 *buffer, size_t bufferSize)
 Compile a script.
void preUpdate (float frameTime)
 Called at the start of a bulletscript update section.
void postUpdate (float frameTime)
 Called at the end of a bulletscript update section.
void createType (const String &name)
 Create a new EmitType.
int getTypeId (const String &name) const
 Get the unique id of the named EmitType.
void releaseType (UserTypeBase *object)
 Releases the object's internal memory.
void updateType (UserTypeBase *object, bstype x, bstype y, bstype angle, float frameTime)
 Update the user object.
int registerEmitFunction (const String &type, const String &name, int numArgs, EmitFunction func)
 Register an EmitFunction for the specified type.
void setDieFunction (const String &type, DieFunction func)
 Give the EmitType a user-defined DieFunction callback, for destroying emitted objects.
int setAnchorX (const String &type, SetFunction set, GetFunction get)
 Set the 'x' property for this EmitType,.
int setAnchorY (const String &type, SetFunction set, GetFunction get)
 Set the 'y' property for this EmitType,.
int setAnchorAngle (const String &type, SetFunction set, GetFunction get)
 Set the 'angle' property for this EmitType,.
int registerProperty (const String &type, const String &name, SetFunction set, GetFunction get)
 Register a controllable property for this EmitType.
int registerAffector (const String &type, const String &name, AffectorFunction func)
 Registers a user AffectorFunction with this type.
int registerNativeFunction (const String &name, bool returnsValue, int numArguments, NativeFunction func)
 Registers native function.
int declareControllerMemberVariable (const String &ctrl, const String &var, bstype value)
 Declares a member variable for a Controller, which can then be used in script.
EmittercreateEmitter (const String &definition, bstype x, bstype y, bstype angle, void *userObject=0)
 Create an Emitter.
void destroyEmitter (Emitter *emit)
 Destroy the specified Emitter.
bool emitterDefinitionExists (const String &name) const
 See whether the named EmitterDefinition exists.
ControllercreateController (const String &definition, bstype x, bstype y, bstype angle, void *userObject=0)
 Create a Controller.
void destroyController (Controller *ctrl)
 Destroy the specified Controller.
bool controllerDefinitionExists (const String &name) const
 See whether the named ControllerDefinition exists.


Detailed Description

Facade class for controlling the system.

This class is used to control all aspects of bulletscript relevant to the user. There can be more than one Machine running at one time, although there is little need for this, as objects within the machine do not communicate with each other.


Member Function Documentation

int BS_NMSP::Machine::compileScript ( const uint8 *  buffer,
size_t  bufferSize 
)

Compile a script.

Parameters:
buffer buffer in which the script is stored.
bufferSize the length of the script buffer.
Returns:
-1 on an internal error, otherwise the number of errors in the script.

bool BS_NMSP::Machine::controllerDefinitionExists ( const String &  name  )  const

See whether the named ControllerDefinition exists.

Parameters:
name name of the ControllerDefinition.
Returns:
true if it exists, false otherwise.

Controller* BS_NMSP::Machine::createController ( const String &  definition,
bstype  x,
bstype  y,
bstype  angle,
void *  userObject = 0 
)

Create a Controller.

Parameters:
definition name of the ControllerDefinition to use (as defined in script).
x initial x position.
y initial y position.
angle initial angle.
userObject an object which the user can pass in.
Returns:
pointer to the newly-created Controller, or 0 if the definition was not found.

Emitter* BS_NMSP::Machine::createEmitter ( const String &  definition,
bstype  x,
bstype  y,
bstype  angle,
void *  userObject = 0 
)

Create an Emitter.

Parameters:
definition name of the EmitterDefinition to use (as defined in script).
x initial x position.
y initial y position.
angle initial angle.
userObject an object which the user can pass in, and can later access from any object created by this Emitter.
Returns:
pointer to the newly-created Emitter, or 0 if the definition was not found.

void BS_NMSP::Machine::createType ( const String &  name  ) 

Create a new EmitType.

This does not check to see if the type already exists.

Parameters:
name name of the EmitType.

int BS_NMSP::Machine::declareControllerMemberVariable ( const String &  ctrl,
const String &  var,
bstype  value 
)

Declares a member variable for a Controller, which can then be used in script.

Parameters:
ctrl name of the Controller.
var name of the variable.
value initial value.
Returns:
BS_OK, or BS_MemberVariableExists if the variable name is already in use.

void BS_NMSP::Machine::destroyController ( Controller ctrl  ) 

Destroy the specified Controller.

Parameters:
ctrl pointer to the Controller.

void BS_NMSP::Machine::destroyEmitter ( Emitter emit  ) 

Destroy the specified Emitter.

Parameters:
emit pointer to the Emitter.

bool BS_NMSP::Machine::emitterDefinitionExists ( const String &  name  )  const

See whether the named EmitterDefinition exists.

Parameters:
name name of the EmitterDefinition.
Returns:
true if it exists, false otherwise.

const Log& BS_NMSP::Machine::getLog (  )  const

Get the bulletscript log.

Returns:
Log object.

int BS_NMSP::Machine::getTypeId ( const String &  name  )  const

Get the unique id of the named EmitType.

This can be used to retrieve an EmitType, to manipulate it directly.

Parameters:
name name of the EmitType.
Returns:
BS_NotFound if the EmitType does not exist, the id otherwise.

void BS_NMSP::Machine::postUpdate ( float  frameTime  ) 

Called at the end of a bulletscript update section.

Parameters:
frameTime the time interval since last update, in seconds.

void BS_NMSP::Machine::preUpdate ( float  frameTime  ) 

Called at the start of a bulletscript update section.

Parameters:
frameTime the time interval since last update, in seconds.

int BS_NMSP::Machine::registerAffector ( const String &  type,
const String &  name,
AffectorFunction  func 
)

Registers a user AffectorFunction with this type.

Affector functions are stored per-EmitType. If the name is already in use, it will be overwritten.

Parameters:
type EmitType to register for.
name name of the function in script.
func AffectorFunction function pointer.
Returns:
BS_OK currently, no checking done.

int BS_NMSP::Machine::registerEmitFunction ( const String &  type,
const String &  name,
int  numArgs,
EmitFunction  func 
)

Register an EmitFunction for the specified type.

Parameters:
type name of the EmitType
name function name to be used in script.
numArgs number of arguments, to be used in parsing.
func pointer to the EmitFunction to use.
Returns:
BS_OK, or BS_EmitFunctionExists is the name is already being used.

int BS_NMSP::Machine::registerGlobalVariable ( const String &  name,
bool  readOnly,
bstype  initialValue 
)

Register a global variable, for use in script.

Parameters:
name variable name.
readOnly whether the variable can be modified in script, or not.
initialValue initial value.
Returns:
BS_OK or BS_GlobalVariableExists if the variable already exists.

int BS_NMSP::Machine::registerNativeFunction ( const String &  name,
bool  returnsValue,
int  numArguments,
NativeFunction  func 
)

Registers native function.

Parameters:
name name of the function in script.
returnsValue whether the function returns a value or nothing.
numArguments the number of arguments the function takes.
func NativeFunction function pointer.
Returns:
BS_OK currently, or BS_NativeFunctionExists if the name is already in use.

int BS_NMSP::Machine::registerProperty ( const String &  type,
const String &  name,
SetFunction  set,
GetFunction  get 
)

Register a controllable property for this EmitType.

You can only set BS_MAX_USER_PROPERTIES properties, defined in bsConfig.h, due to performance reasons.

Parameters:
type EmitType to register for.
name property name.
set user-defined SetFunction.
get user-defined GetFunction.
Returns:
BS_OK, BS_PropertyExists if the property already exists, BS_TooManyProperties if there are too many properties.

void BS_NMSP::Machine::releaseType ( UserTypeBase object  ) 

Releases the object's internal memory.

The user should call this function on an object when they delete that object.

Parameters:
object pointer to user object.

int BS_NMSP::Machine::setAnchorAngle ( const String &  type,
SetFunction  set,
GetFunction  get 
)

Set the 'angle' property for this EmitType,.

This property must be set differently, because it is built-in, and used as an anchor.

Parameters:
type EmitType to register for.
set user-defined SetFunction.
get user-defined GetFunction.
Returns:
BS_OK

int BS_NMSP::Machine::setAnchorX ( const String &  type,
SetFunction  set,
GetFunction  get 
)

Set the 'x' property for this EmitType,.

This property must be set differently, because it is built-in, and used as an anchor.

Parameters:
type EmitType to register for.
set user-defined SetFunction.
get user-defined GetFunction.
Returns:
BS_OK

int BS_NMSP::Machine::setAnchorY ( const String &  type,
SetFunction  set,
GetFunction  get 
)

Set the 'y' property for this EmitType,.

This property must be set differently, because it is built-in, and used as an anchor.

Parameters:
type EmitType to register for.
set user-defined SetFunction.
get user-defined GetFunction.
Returns:
BS_OK

void BS_NMSP::Machine::setDieFunction ( const String &  type,
DieFunction  func 
)

Give the EmitType a user-defined DieFunction callback, for destroying emitted objects.

Unlike EmitFunctions, there can only be one DieFunction registered per EmitType.

Parameters:
type EmitType to register for.
func pointer to the function.

void BS_NMSP::Machine::setGlobalVariableValue ( const String &  name,
bstype  value 
)

Set the named global variable.

If the variable is not found, nothing happens.

Parameters:
name variable name.
value value to set to.

void BS_NMSP::Machine::updateType ( UserTypeBase object,
bstype  x,
bstype  y,
bstype  angle,
float  frameTime 
)

Update the user object.

The user should call this on each object that they want bulletscript to update. It should be called between preUpdate() and postUpdate().

Parameters:
object pointer to user object.
x x position of the user object.
y y position of the user object.
angle angle of the user object.
frameTime the time interval since last update, in seconds.


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

Generated on Wed Mar 31 12:49:05 2010 for bulletscript by  doxygen 1.5.9