}
+static int Level_toggle_pause_wrapper(HSQUIRRELVM vm)
+{
+ Scripting::Level* _this;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, reinterpret_cast<SQUserPointer*> (&_this), 0))) {
+ sq_throwerror(vm, _SC("'toggle_pause' called without instance"));
+ return SQ_ERROR;
+ }
+
+ try {
+ _this->toggle_pause();
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'toggle_pause'"));
+ return SQ_ERROR;
+ }
+
+}
+
static int ScriptedObject_release_hook(SQUserPointer ptr, int )
{
Scripting::ScriptedObject* _this = reinterpret_cast<Scripting::ScriptedObject*> (ptr);
}
+static int Player_kill_wrapper(HSQUIRRELVM vm)
+{
+ Scripting::Player* _this;
+ if(SQ_FAILED(sq_getinstanceup(vm, 1, reinterpret_cast<SQUserPointer*> (&_this), 0))) {
+ sq_throwerror(vm, _SC("'kill' called without instance"));
+ return SQ_ERROR;
+ }
+ SQBool arg0;
+ if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) {
+ sq_throwerror(vm, _SC("Argument 1 not a bool"));
+ return SQ_ERROR;
+ }
+
+ try {
+ _this->kill(arg0);
+
+ return 0;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'kill'"));
+ return SQ_ERROR;
+ }
+
+}
+
static int FloatingImage_release_hook(SQUserPointer ptr, int )
{
Scripting::FloatingImage* _this = reinterpret_cast<Scripting::FloatingImage*> (ptr);
}
-static int shrink_wrapper(HSQUIRRELVM vm)
-{
- (void) vm;
-
- try {
- Scripting::shrink();
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'shrink'"));
- return SQ_ERROR;
- }
-
-}
-
-static int kill_wrapper(HSQUIRRELVM vm)
-{
- (void) vm;
-
- try {
- Scripting::kill();
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'kill'"));
- return SQ_ERROR;
- }
-
-}
-
static int restart_wrapper(HSQUIRRELVM vm)
{
(void) vm;
}
+static int rand_wrapper(HSQUIRRELVM vm)
+{
+
+ try {
+ int return_value = Scripting::rand();
+
+ sq_pushinteger(vm, return_value);
+ return 1;
+
+ } catch(std::exception& e) {
+ sq_throwerror(vm, e.what());
+ return SQ_ERROR;
+ } catch(...) {
+ sq_throwerror(vm, _SC("Unexpected exception while executing function 'rand'"));
+ return SQ_ERROR;
+ }
+
+}
+
} // end of namespace Wrapper
void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook)
throw SquirrelError(v, "Couldn't register function 'mortal'");
}
- sq_pushstring(v, "shrink", -1);
- sq_newclosure(v, &shrink_wrapper, 0);
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'shrink'");
- }
-
- sq_pushstring(v, "kill", -1);
- sq_newclosure(v, &kill_wrapper, 0);
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'kill'");
- }
-
sq_pushstring(v, "restart", -1);
sq_newclosure(v, &restart_wrapper, 0);
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register function 'quit'");
}
+ sq_pushstring(v, "rand", -1);
+ sq_newclosure(v, &rand_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'rand'");
+ }
+
// Register class DisplayEffect
sq_pushstring(v, "DisplayEffect", -1);
if(sq_newclass(v, SQFalse) < 0) {
throw SquirrelError(v, "Couldn't register function 'flip_vertically'");
}
+ sq_pushstring(v, "toggle_pause", -1);
+ sq_newclosure(v, &Level_toggle_pause_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'toggle_pause'");
+ }
+
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register class 'Level'");
}
throw SquirrelError(v, "Couldn't register function 'get_visible'");
}
+ sq_pushstring(v, "kill", -1);
+ sq_newclosure(v, &Player_kill_wrapper, 0);
+ if(SQ_FAILED(sq_createslot(v, -3))) {
+ throw SquirrelError(v, "Couldn't register function 'kill'");
+ }
+
if(SQ_FAILED(sq_createslot(v, -3))) {
throw SquirrelError(v, "Couldn't register class 'Player'");
}