X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Fwrapper.cpp;h=d3c8cf1af6c9d107b184ff9e6ee49827f3d4c705;hb=c3c41a343669d375aaa674c7f3ac35f08f24703e;hp=cda1f24d43a86bbaedb3e7960a4f06e46752aeeb;hpb=30354244be4770a09eb46441af28c95229a90a99;p=supertux.git diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index cda1f24d4..d3c8cf1af 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -485,6 +485,35 @@ static SQInteger Level_toggle_pause_wrapper(HSQUIRRELVM vm) } +static SQInteger Level_edit_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'edit' called without instance")); + return SQ_ERROR; + } + Scripting::Level* _this = reinterpret_cast (data); + SQBool arg0; + if(SQ_FAILED(sq_getbool(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a bool")); + return SQ_ERROR; + } + + try { + _this->edit(arg0 == SQTrue); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'edit'")); + return SQ_ERROR; + } + +} + static SQInteger ScriptedObject_release_hook(SQUserPointer ptr, SQInteger ) { Scripting::ScriptedObject* _this = reinterpret_cast (ptr); @@ -2849,6 +2878,35 @@ static SQInteger SSector_get_ambient_blue_wrapper(HSQUIRRELVM vm) } +static SQInteger SSector_set_gravity_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'set_gravity' called without instance")); + return SQ_ERROR; + } + Scripting::SSector* _this = reinterpret_cast (data); + SQFloat arg0; + if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a float")); + return SQ_ERROR; + } + + try { + _this->set_gravity(static_cast (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 'set_gravity'")); + return SQ_ERROR; + } + +} + static SQInteger LevelTime_release_hook(SQUserPointer ptr, SQInteger ) { Scripting::LevelTime* _this = reinterpret_cast (ptr); @@ -3507,6 +3565,29 @@ static SQInteger play_sound_wrapper(HSQUIRRELVM vm) } +static SQInteger set_game_speed_wrapper(HSQUIRRELVM vm) +{ + SQFloat arg0; + if(SQ_FAILED(sq_getfloat(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a float")); + return SQ_ERROR; + } + + try { + Scripting::set_game_speed(static_cast (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 'set_game_speed'")); + return SQ_ERROR; + } + +} + static SQInteger grease_wrapper(HSQUIRRELVM vm) { (void) vm; @@ -4298,6 +4379,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'play_sound'"); } + sq_pushstring(v, "set_game_speed", -1); + sq_newclosure(v, &set_game_speed_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_game_speed'"); + } + sq_pushstring(v, "grease", -1); sq_newclosure(v, &grease_wrapper, 0); if(SQ_FAILED(sq_createslot(v, -3))) { @@ -4477,6 +4564,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'toggle_pause'"); } + sq_pushstring(v, "edit", -1); + sq_newclosure(v, &Level_edit_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'edit'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'Level'"); } @@ -5102,6 +5195,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'get_ambient_blue'"); } + sq_pushstring(v, "set_gravity", -1); + sq_newclosure(v, &SSector_set_gravity_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_gravity'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'SSector'"); }