MScriptContext
(Difference between revisions)
Dahnielson (Talk | contribs) |
Dahnielson (Talk | contribs) |
||
Line 1: | Line 1: | ||
+ | {{:classMScriptContext}} | ||
+ | |||
MScriptContext is used to manage script functions virtually. | MScriptContext is used to manage script functions virtually. | ||
Revision as of 01:15, 8 February 2014
Class used to manage script functions virtually.
API
virtual MScriptContext::~MScriptContext(void)
Destructor.
virtual void MScriptContext::runScript(const char *filename)=0
Run script.
virtual bool MScriptContext::startCallFunction(const char *name)=0
Start call function.
virtual bool MScriptContext::endCallFunction(int numArgs=0)=0
End call script function.
virtual void MScriptContext::callFunction(const char *name)=0
Call script function.
virtual void MScriptContext::addFunction(const char *name, int(*function)(void))=0
Add script function.
virtual unsigned int MScriptContext::getArgsNumber(void)=0
virtual void MScriptContext::getIntArray(unsigned int arg, int *values, unsigned int valuesNumber)=0
virtual void MScriptContext::getFloatArray(unsigned int arg, float *values, unsigned int valuesNumber)=0
virtual const char* MScriptContext::getString(unsigned int arg)=0
virtual int MScriptContext::getInteger(unsigned int arg)=0
virtual float MScriptContext::getFloat(unsigned int arg)=0
virtual void* MScriptContext::getPointer(unsigned int arg)=0
virtual void MScriptContext::pushIntArray(const int *values, unsigned int valuesNumber)=0
virtual void MScriptContext::pushFloatArray(const float *values, unsigned int valuesNumber)=0
virtual void MScriptContext::pushString(const char *string)=0
virtual void MScriptContext::pushBoolean(bool value)=0
virtual void MScriptContext::pushInteger(int value)=0
virtual void MScriptContext::pushFloat(float value)=0
virtual void MScriptContext::pushPointer(void *value)=0
MScriptContext is used to manage script functions virtually.
Custom functions can be declared during a plugin initialization in c++,
you can send values to the script context using pushInt, pushString, etc,
and get arguments from a script call using getInteger, getString, etc
exemple :
#include <MEngine.h> #include "MyPlugin.h" int myFunction(void) { MEngine * engine = MEngine::getInstance(); MScriptContext * script = engine->getScriptContext(); script->pushString("Hello World !"); return 1; // return 1 because the function is sending 1 value to the context (use 0 for none, 2 for 2 values...) } void StartPlugin(void) { MEngine * engine = MEngine::getInstance(); MScriptContext* script = engine->getScriptContext(); script->addFunction("myFunction", myFunction); }
In lua the function will be used like this :
text = myFunction() -- "Hello World !"