Added exit() JS function
This was SVN commit r673.
This commit is contained in:
parent
dc5e5dd774
commit
fcb85a5968
@ -254,6 +254,12 @@ static void WriteScreenshot()
|
||||
bool active = true;
|
||||
static bool quit = false; // break out of main loop
|
||||
|
||||
// HACK: Let code from other files (i.e. the scripting system) quit
|
||||
void kill_mainloop()
|
||||
{
|
||||
quit = true;
|
||||
}
|
||||
|
||||
static int handler(const SDL_Event* ev)
|
||||
{
|
||||
int c;
|
||||
|
@ -30,6 +30,7 @@ JSFunctionSpec ScriptFunctionTable[] =
|
||||
{"getEntityTemplate", getEntityTemplate, 1, 0, 0 },
|
||||
{"getGUIObjectByName", JSI_IGUIObject::getByName, 1, 0, 0 },
|
||||
{"getGlobal", getGlobal, 0, 0, 0 },
|
||||
{"exit", exitProgram, 0, 0, 0 },
|
||||
{0, 0, 0, 0, 0},
|
||||
};
|
||||
|
||||
@ -129,3 +130,11 @@ JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc,
|
||||
return( JS_TRUE );
|
||||
}
|
||||
|
||||
|
||||
extern void kill_mainloop(); // from main.cpp
|
||||
|
||||
JSBool exitProgram(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval)
|
||||
{
|
||||
kill_mainloop();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
@ -13,7 +13,10 @@ JSBool getEntityByHandle( JSContext* context, JSObject* globalObject, unsigned i
|
||||
JSBool getEntityTemplate( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval );
|
||||
|
||||
// Returns the global object, e.g. for setting global variables.
|
||||
JSBool getGlobal( JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval );
|
||||
JSBool getGlobal(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval);
|
||||
|
||||
// Tells the main loop to stop looping
|
||||
JSBool exitProgram(JSContext* context, JSObject* globalObject, unsigned int argc, jsval* argv, jsval* rval);
|
||||
|
||||
extern JSFunctionSpec ScriptFunctionTable[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user