QScript API


CreateModule

QScriptModule CreateModule(const char* name, QModuleDefFunc* funcs)

Takes a name, and a QModuleDefFunc list, returns a QScriptModule


LoadMods

void LoadMods(const char* filename)

Will load a file inside the root of every mod.


LoadModsInDirectory

void LoadModsInDirectory(const char* folder, const char* filename)

Acts like LoadMods, but loads a file inside a subdirectory. (mods/*/folder/filename.*)


StartClass

QScriptClassCreator StartClass(const char* name, QScriptClass parent)

Returns a QScriptClassCreator


AddMethod

void AddMethod(QScriptClassCreator creator, const char* name, QType* params, QCFunc func, bool is_private = false)

Adds a method to the class creator. Takes a name, QType list which will be the parameters, QCFunc which will be the callback, and an optional is_private bool.


AddScriptingMethod

void AddScriptingMethod(QScriptClassCreator creator, const char* name, QScriptCallback callback, bool is_private)

Adds a scripting language method for the class creator. Takes a name, QScriptCallback which will be called when the method is called, and an optional is_private bool.


AddVariable

void AddVariable(QScriptClassCreator creator, const char* name, QType type, QValue defaultval, bool is_private)

Adds a variable with a default value to the class creator. Takes a name, QType, QValue, and an optional is_private bool.

Do not use this for adding strings. Use the next method instead.


AddString

void AddString(QScriptClassCreator creator, const char* name, const char* defaultval, bool is_private)

Adds a string variable to the class creator. Takes a name, a default value and an optional is_private bool.


FinishClass

QScriptClass FinishClass(QScriptClassCreator creator)

Finishes the class creator and returns a QScriptClass. Will delete the creator.


CreateObject

QScriptObject CreateObject(QScriptClass cls)

Returns a new QScriptObject. Takes a class from which to create the object.


InitializeObject

void InitializeObject(QScriptObject object)

Initializes a QScriptObject. Call every time after you create one! Takes a QScriptObject.


GetObjectValueIndex

int GetObjectValueIndex(QScriptObject object, const char* name)

Gets a index of a variable from the object. Takes a QScriptObject and a name of the variable.


SetObjectValue

void SetObjectValue(QScriptObject object, int index, QValue val)

Sets a value inside an object. Takes the object, the index of the value, and a QValue. Do not use this function for setting strings.


SetObjectString

void SetObjectString(QScriptObject object, int index, const char* str)

Sets a string inside an object. Takes the object, the index of the value and a string.


GetObjectValue

QValue GetObjectValue(QScriptObject object, int index)

Gets a value from an object. Returns a QValue and takes the object and the index of the value.


GetObjectValueType

QType GetObjectValueType(QScriptObject object, int index)

Gets the type of a value in the object. Takes the object and the index of the value. Returns a QType.


GetObjectMethodIndex

int GetObjectMethodIndex(QScriptObject object, const char* name)

Gets the index of a method in the object. Takes the object and the name of the method.


GetObjectMethod

QScriptFunction GetObjectMethod(QScriptObject object, int index)

Gets the method of an object. Takes the object and the index of the method. Returns a QScriptFunction.


CallObjectMethod

QReturn CallObjectMethod(QScriptObject object, int index, QScriptArgs arguments);

Calls a method from the object. Takes the object, index of the method and QScriptArgs.


GetArgValue

QValue GetArgValue(QScriptArgs args, int index)

Gets a value from some arguments. Takes a QScriptArgs and the argument index.


GetArgType

QType GetArgType(QScriptArgs args, int index)

Gets the type of the argument from a QScriptArgs. Takes a QScriptArgs and the argument index.


CallFunction

void CallFunction(QScriptFunction function, const char* fmt, ...)

Calls a QScriptFunction, takes a string which represents the types of arguments and a vararg which are the arguments themselves. The arguments are normal C++ types.

Here is a table of chars to QType

char QType
s QType_String
i QType_Int
f QType_Float
o QType_Object
b QType_Bool
p QType_Function