X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Fwrapper.cpp;h=f50fa6c00d5441bf2e72cf623aaf3649eef5b2d7;hb=86e5914510fc29f4decbb66a7d602872b6c8555e;hp=a47c84ec25569bf5ba905c8956dd7cec63281821;hpb=bbc091a52439e4942cfa614a6c16b3f530dfab8a;p=supertux.git diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index a47c84ec2..f50fa6c00 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); @@ -1658,6 +1687,69 @@ static SQInteger Player_trigger_sequence_wrapper(HSQUIRRELVM vm) } +static SQInteger Player_use_scripting_controller_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'use_scripting_controller' called without instance")); + return SQ_ERROR; + } + Scripting::Player* _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->use_scripting_controller(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 'use_scripting_controller'")); + return SQ_ERROR; + } + +} + +static SQInteger Player_do_scripting_controller_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'do_scripting_controller' called without instance")); + return SQ_ERROR; + } + Scripting::Player* _this = reinterpret_cast (data); + const SQChar* arg0; + if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { + sq_throwerror(vm, _SC("Argument 1 not a string")); + return SQ_ERROR; + } + SQBool arg1; + if(SQ_FAILED(sq_getbool(vm, 3, &arg1))) { + sq_throwerror(vm, _SC("Argument 2 not a bool")); + return SQ_ERROR; + } + + try { + _this->do_scripting_controller(arg0, arg1 == 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 'do_scripting_controller'")); + return SQ_ERROR; + } + +} + static SQInteger FloatingImage_release_hook(SQUserPointer ptr, SQInteger ) { Scripting::FloatingImage* _this = reinterpret_cast (ptr); @@ -2786,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); @@ -2960,6 +3081,54 @@ static SQInteger WillOWisp_set_state_wrapper(HSQUIRRELVM vm) } +static SQInteger WillOWisp_start_moving_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'start_moving' called without instance")); + return SQ_ERROR; + } + Scripting::WillOWisp* _this = reinterpret_cast (data); + + try { + _this->start_moving(); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'start_moving'")); + return SQ_ERROR; + } + +} + +static SQInteger WillOWisp_stop_moving_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'stop_moving' called without instance")); + return SQ_ERROR; + } + Scripting::WillOWisp* _this = reinterpret_cast (data); + + try { + _this->stop_moving(); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'stop_moving'")); + return SQ_ERROR; + } + +} + static SQInteger display_wrapper(HSQUIRRELVM vm) { return Scripting::display(vm); @@ -3396,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; @@ -3548,6 +3740,29 @@ static SQInteger camera_wrapper(HSQUIRRELVM vm) } +static SQInteger set_gamma_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_gamma(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_gamma'")); + return SQ_ERROR; + } + +} + static SQInteger quit_wrapper(HSQUIRRELVM vm) { (void) vm; @@ -4187,6 +4402,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))) { @@ -4235,6 +4456,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'camera'"); } + sq_pushstring(v, "set_gamma", -1); + sq_newclosure(v, &set_gamma_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_gamma'"); + } + sq_pushstring(v, "quit", -1); sq_newclosure(v, &quit_wrapper, 0); if(SQ_FAILED(sq_createslot(v, -3))) { @@ -4366,6 +4593,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'"); } @@ -4651,6 +4884,18 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'trigger_sequence'"); } + sq_pushstring(v, "use_scripting_controller", -1); + sq_newclosure(v, &Player_use_scripting_controller_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'use_scripting_controller'"); + } + + sq_pushstring(v, "do_scripting_controller", -1); + sq_newclosure(v, &Player_do_scripting_controller_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'do_scripting_controller'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'Player'"); } @@ -4979,6 +5224,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'"); } @@ -5037,6 +5288,18 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'set_state'"); } + sq_pushstring(v, "start_moving", -1); + sq_newclosure(v, &WillOWisp_start_moving_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'start_moving'"); + } + + sq_pushstring(v, "stop_moving", -1); + sq_newclosure(v, &WillOWisp_stop_moving_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'stop_moving'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'WillOWisp'"); }