Squirrel Plugins
I worked a little bit on the squirrel Bindings They work now on linux and windows :) (OSX is untested, but should work also) but they are very limited at the moment. (Only made OnChat working) I also fixed some small bugs. git-svn-id: http://mc-server.googlecode.com/svn/trunk@648 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
65
source/squirrelbindings/SquirrelFunctions.cpp
Normal file
65
source/squirrelbindings/SquirrelFunctions.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
#include "Globals.h"
|
||||
#include "SquirrelFunctions.h"
|
||||
#include "SquirrelBindings.h"
|
||||
|
||||
static HSQUIRRELVM squirrelvm = NULL;
|
||||
|
||||
SQInteger runtimeErrorHandler(HSQUIRRELVM a_VM)
|
||||
{
|
||||
const SQChar *sErr = 0;
|
||||
if(sq_gettop(a_VM) >= 1)
|
||||
{
|
||||
if(SQ_SUCCEEDED(sq_getstring(a_VM, 2, &sErr)))
|
||||
{
|
||||
LOGERROR("Squirrel Error: %s", sErr);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGERROR("Squirrel Error: Unknown Error");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void compilerErrorHandler(HSQUIRRELVM v,
|
||||
const SQChar* a_Desc,
|
||||
const SQChar* a_Source,
|
||||
SQInteger a_Line,
|
||||
SQInteger a_Column)
|
||||
{
|
||||
|
||||
LOGERROR("Squirrel Error: %s (%d:%d) %s", a_Source, a_Line, a_Column, a_Desc);
|
||||
}
|
||||
|
||||
HSQUIRRELVM OpenSquirrelVM()
|
||||
{
|
||||
if(!squirrelvm)
|
||||
{
|
||||
squirrelvm = sq_open(1024);
|
||||
Sqrat::DefaultVM::Set(squirrelvm);
|
||||
|
||||
sq_newclosure(squirrelvm, runtimeErrorHandler, 0);
|
||||
sq_seterrorhandler(squirrelvm);
|
||||
|
||||
sq_setcompilererrorhandler(squirrelvm, compilerErrorHandler);
|
||||
|
||||
BindSquirrel(squirrelvm);
|
||||
}
|
||||
return squirrelvm;
|
||||
}
|
||||
|
||||
void CloseSquirrelVM()
|
||||
{
|
||||
if(squirrelvm)
|
||||
{
|
||||
sq_close(squirrelvm);
|
||||
squirrelvm = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void sqPrint(SQChar * text)
|
||||
{
|
||||
LOGINFO("%s", text);
|
||||
}
|
||||
Reference in New Issue
Block a user