X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Fwrapper.cpp;h=6ee9ab6f8062d1403319cfcc7e1605a676751599;hb=c38774eb23527f0e99a3d90e023ade6074100144;hp=8307bacc4390138e62a01d0c1a7333d63bebfc09;hpb=cc2776a002549ae37ecf78be1333e66282780064;p=supertux.git diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 8307bacc4..6ee9ab6f8 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -1467,6 +1467,35 @@ static SQInteger Player_do_jump_wrapper(HSQUIRRELVM vm) } +static SQInteger Player_trigger_sequence_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'trigger_sequence' 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; + } + + try { + _this->trigger_sequence(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 'trigger_sequence'")); + return SQ_ERROR; + } + +} + static SQInteger FloatingImage_release_hook(SQUserPointer ptr, SQInteger ) { Scripting::FloatingImage* _this = reinterpret_cast (ptr); @@ -1802,6 +1831,64 @@ static SQInteger FloatingImage_get_action_wrapper(HSQUIRRELVM vm) } +static SQInteger FloatingImage_fade_in_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'fade_in' called without instance")); + return SQ_ERROR; + } + Scripting::FloatingImage* _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->fade_in(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 'fade_in'")); + return SQ_ERROR; + } + +} + +static SQInteger FloatingImage_fade_out_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0))) { + sq_throwerror(vm, _SC("'fade_out' called without instance")); + return SQ_ERROR; + } + Scripting::FloatingImage* _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->fade_out(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 'fade_out'")); + return SQ_ERROR; + } + +} + static SQInteger Platform_release_hook(SQUserPointer ptr, SQInteger ) { Scripting::Platform* _this = reinterpret_cast (ptr); @@ -4132,6 +4219,12 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'do_jump'"); } + sq_pushstring(v, "trigger_sequence", -1); + sq_newclosure(v, &Player_trigger_sequence_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'trigger_sequence'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'Player'"); } @@ -4215,6 +4308,18 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'get_action'"); } + sq_pushstring(v, "fade_in", -1); + sq_newclosure(v, &FloatingImage_fade_in_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'fade_in'"); + } + + sq_pushstring(v, "fade_out", -1); + sq_newclosure(v, &FloatingImage_fade_out_wrapper, 0); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'fade_out'"); + } + if(SQ_FAILED(sq_createslot(v, -3))) { throw SquirrelError(v, "Couldn't register class 'FloatingImage'"); }