From: Mathnerd314 Date: Sun, 3 Aug 2014 17:47:10 +0000 (+0200) Subject: Flesh out the intro scene some more. X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dae274f7bc4ae7914207586dd7e7b1cfc5f3a98f;p=supertux.git Flesh out the intro scene some more. * Tux actually does stuff during the music * Dialogue Also some misc. tweaks to silence GCC warnings (parser.cpp and main.cpp) --- diff --git a/data/images/engine/menu/logo.sprite b/data/images/engine/menu/logo.sprite new file mode 100644 index 000000000..902f41a7a --- /dev/null +++ b/data/images/engine/menu/logo.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "logo.png") + ) +) diff --git a/data/images/tiles/signs/right.sprite b/data/images/tiles/signs/right.sprite new file mode 100644 index 000000000..f2da39f2d --- /dev/null +++ b/data/images/tiles/signs/right.sprite @@ -0,0 +1,6 @@ +(supertux-sprite + (action + (name "default") + (images "right.png") + ) +) diff --git a/data/levels/world1/intro.nut b/data/levels/world1/intro.nut index e68e041f4..46fae6529 100644 --- a/data/levels/world1/intro.nut +++ b/data/levels/world1/intro.nut @@ -1,85 +1,190 @@ -function intro() +function initialize() { - //initialize - Camera.set_mode("manual"); - Tux.deactivate(); -// Tux.set_position(2291,1280); Tux.add_bonus("grow"); RADIO.set_action("quiet"); PENNY.set_action("stand-left"); NOLOK.set_visible(false); - logo <- FloatingImage("images/objects/logo/logo.sprite"); - Effect.sixteen_to_nine(0); + LOGO.set_visible(false); + LOGO.enable_gravity(false); + SIGN.set_visible(false); +} - //begin scrolling sequence - Effect.fade_in(2); - Camera.scroll_to(0, 945, 15); +function logo_in() +{ + local x = LOGO.get_pos_x(); + local y = LOGO.get_pos_y(); + local time = 1.5; + LOGO.set_pos(x,-120); + LOGO.set_visible(true); + LOGO.set_velocity(0,(120+y)/time); + LOGO.enable_gravity(false); + wait(time); + LOGO.set_velocity(0,0); wait(3); + LOGO.set_visible(false); +} + +function intro_text() +{ Text.set_text(translate ("Somewhere at the shores\nof Antarctica...")); - Text.fade_in(2); - wait(3); - Text.fade_out(2); - wait(10); - Tux.walk(0); - Camera.scroll_to(3100, 945, 18); - wait(6); - logo.set_anchor_point(ANCHOR_TOP); - logo.set_pos(0, -120); - logo.set_visible(true); - logo.fade_in(2); - logo_in(); - wait(6); - logo.fade_out(2); - wait(2); - logo.set_visible(false); - wait(5.3); + Text.fade_in(1); + wait(1); + Text.fade_out(1); +} +function rap_scene() +{ + Tux.deactivate(); //begin conversation and Tux rap - Tux.walk(0); - play_sound("speech/tux_hello.ogg"); - wait(3); - play_sound("speech/penny_runt_01.ogg"); + play_sound("speech/tux_hello.ogg"); // 3.1 seconds + Text.set_centered(false); + Text.set_text(translate ("Tux: Hello Penny")); + Text.fade_in(1); + wait(2.5); + Text.fade_out(1); + wait(1); + play_sound("speech/penny_runt_01.ogg"); // 1.2 seconds + Text.set_text(translate ("Penny: Hey Tux")); + Text.fade_in(0.5); wait(1); - play_sound("speech/tux_murp_01.ogg"); + Text.fade_out(0.5); + wait(0.5); + play_sound("speech/tux_murp_01.ogg"); // 1.5 seconds + Text.set_text(translate ("Tux: Check out my dance moves.")); + Text.fade_in(0.5); wait(1); + Text.fade_out(0.5); + wait(0.5); RADIO.set_action("loud"); - play_sound("speech/tux_rap.ogg"); - wait(15); - shake_bush(); - wait(2); - shake_bush(); - wait(2); - shake_bush(); - wait(1.3); - - //enter Nolok - NOLOK.set_velocity(-220, 600); - NOLOK.set_visible(true); - Effect.fade_out(1.3); - wait(3); - - //darkness + play_sound("speech/tux_rap.ogg"); // 24.6 seconds + local t = ::newthread(shake_bush_thread); + t.call(this); // Nolok's waiting... + // meanwhile... Tux dances! + // TODO: add some more dance moves besides jumps, ducks, & flips + // and fill in the parts where he just stands still + wait(6); // music intro - 6 seconds + Tux.do_duck(); + Tux.set_dir(false); + wait(0.40625); // all times rounded to nearest 1/64 of a second + Tux.do_standup(); + Tux.kick(); // 0.3 seconds + wait(0.40625); + Tux.set_dir(true); + wait(0.203125); + Tux.set_dir(false); + wait(0.203125); + Tux.set_dir(true); + wait(0.09375); + Tux.do_duck(); // t=7.3 + wait(0.5); + Tux.set_dir(false); + wait(0.203125); + Tux.set_dir(true); + wait(0.203125); + Tux.set_dir(false); + wait(0.203125); + Tux.set_dir(true); + wait(0.203125); + Tux.set_dir(false); + wait(0.203125); + Tux.set_dir(true); + Tux.do_standup(); // t=8.8 + wait(0.203125); + Tux.set_dir(false); + wait(0.203125); + Tux.kick(); + wait(0.40625); + Tux.set_dir(true); + Tux.do_jump(-300); + wait(0.703125); + Tux.do_duck(); // t=10.7 + wait(0.296875); + Tux.set_dir(false); + wait(0.59375); + Tux.set_dir(true); + wait(0.703125); + Tux.do_standup(); // t=12.3 + Tux.kick(); + wait(0.5); + Tux.do_duck(); + wait(0.5); + Tux.do_backflip(); // t=13.3 + wait(79.0/64); + Tux.walk(200); + wait(38.0/64); + Tux.walk(0); + wait(184.0/64); + Tux.set_dir(false); //t=18.0 + wait(0.3) + Tux.kick(); + wait(0.40625); + Tux.do_duck(); + Tux.set_dir(true); + wait(0.296875); + Tux.set_dir(false); // t=19.0 + wait(0.5); + Tux.do_standup(); + Tux.do_jump(-800); + wait(1.5); + Tux.kick(); // t=21 + wait(0.5); + Tux.do_duck(); + wait(0.5); + Tux.do_jump(-400); + wait(1.0); + Tux.do_standup(); + wait(0.796875); + Tux.set_dir(true); //t=23.8 - Tux sees Nolok! + Tux.do_jump(-520); + wait(151.0/64); + // we have to activate Tux to hurt him + Tux.activate(); + Tux.kill(false); + Tux.deactivate(); + wait(1.5); + // song is done + // darkness NOLOK.set_visible(false); + NOLOK.set_solid(false); PENNY.set_visible(false); - RADIO.set_action("quiet"); -// Tux.set_position(3550, 1270); - + PENNY.set_solid(false); + RADIO.set_visible(false); + RADIO.set_solid(false); + SIGN.set_visible(true); //wake up, Tux... - Effect.fade_in(4); - wait(4); - play_sound("speech/tux_upset.ogg"); - wait(3); - tux_upset(); + Effect.fade_in(3); + play_sound("speech/tux_upset.ogg"); // 11 seconds + Text.set_text(translate ("Tux: Oww... my head...")); + Text.fade_in(1); + wait(1.9); + Tux.activate(); + Text.fade_out(0.3); + wait(0.5); + Text.set_text(translate ("Tux: Wait!")); // t=2.4 + Text.fade_in(0.5); + wait(1); + Text.fade_out(0.5); + wait(0.5); + Text.set_text(translate ("Tux: Penny!")); // t=3.9 + Text.fade_in(0.5); wait(1); - tux_upset(); - wait(4); - Tux.walk(3000); + Text.fade_out(0.5); + wait(0.5); + Text.set_text(translate ("Tux: Where are you, Penny?!")); // t=4.4 + Text.fade_in(0.5); wait(2); - - //end intro sequence - Effect.fade_out(2); - wait(3); - Level.finish(true); + Text.fade_out(0.5); + wait(0.5); + Text.set_text(translate ("Tux: Oh no...")); // t=6.9 + Text.fade_in(0.5); + wait(1); + Text.fade_out(0.5); + wait(0.5); + Text.set_text(translate ("Tux: Don't worry, Penny, I'll rescue you!")); // t=8.4 + Text.fade_in(0.5); + wait(2); + Text.fade_out(0.5); + wait(0.5); } function shake_bush() @@ -87,28 +192,60 @@ function shake_bush() //play_sound("sounds/rustle.wav"); local bushx = BUSH.get_pos_x(); local bushy = BUSH.get_pos_y(); - for(local i = 0; i < 20; ++i) { + for(local i = 0; i < 21; ++i) { BUSH.set_pos(bushx + ( rand() % 6 ) - 3, bushy); - wait(0.05); + wait(0.046875); } + wait(0.015625); } -function tux_upset() +function shake_bush_thread(table) { - Tux.walk(200); - wait(1); - Tux.walk(0); - wait(1); - Tux.walk(-200); - wait(1); - Tux.walk(0); + table.wait(8); + table.shake_bush(); // each bush shake lasts 1 second + table.wait(5); + table.shake_bush(); + table.wait(3); + table.shake_bush(); + table.wait(2); + table.shake_bush(); + table.shake_bush(); // total 23 seconds + //enter Nolok + table.NOLOK.set_velocity(-220, 600); + table.NOLOK.set_visible(true); + table.Effect.fade_out(1.3); } -function logo_in() +function end_level() { - local i; - for(local i = -120; i <= 90; i+=2) { - logo.set_pos(0, i); - wait(0.01); - } + //end intro sequence + Effect.fade_out(2); + wait(2.1); + Level.finish(true); } + +state_idx <- 0; +states <- { init=0, start=1, logo_in=2, intro_text=3, rap_scene=4, end_level=5}; +function trigger_state(state) { + local idx = states[state]; + if(!idx || idx <= state_idx) + return; + state_idx = idx; + switch(state) { + case "start": + initialize(); + break; + case "logo_in": + logo_in(); + break; + case "intro_text": + intro_text(); + break; + case "rap_scene": + rap_scene(); + break; + case "end_level": + end_level(); + break; + } +} \ No newline at end of file diff --git a/data/levels/world1/intro.stl b/data/levels/world1/intro.stl index 312987748..44bc63ce9 100644 --- a/data/levels/world1/intro.stl +++ b/data/levels/world1/intro.stl @@ -3,35 +3,30 @@ (name (_ "Picnic With Penny")) (author "SuperTux Team") (license "GPL 2+ / CC-by-sa 3.0") + (target-time 0) (sector (name "main") (music "music/intro.ogg") - (init-script " Tux.add_bonus(\"grow\"); - RADIO.set_action(\"quiet\"); - PENNY.set_action(\"stand-left\"); - NOLOK.set_visible(false); + (init-script "import(\"levels/world1/intro.nut\"); +trigger_state(\"start\"); ") (ambient-light 1 1 1) (camera (mode "normal") ) - (decal - (x 1600) - (y 1056) - (sprite "images/engine/menu/logo.png") - ) (gradient (top_color 0 0.85 1) (bottom_color 0 0.6 1) ) (scriptedobject - (name "PENNY") - (visible #t) + (name "LOGO") + (layer 10) + (visible #f) (physic-enabled #t) - (solid #t) - (sprite "images/creatures/penny/penny.sprite") - (x 3489) - (y 1280) + (solid #f) + (sprite "images/engine/menu/logo.sprite") + (x 1568) + (y 1024) ) (scriptedobject (name "RADIO") @@ -44,7 +39,6 @@ ) (scriptedobject (name "BUSH") - (z-pos 0) (visible #t) (physic-enabled #f) (solid #f) @@ -61,75 +55,60 @@ (x 3631) (y 1276) ) + (scriptedobject + (name "PENNY") + (visible #t) + (physic-enabled #t) + (solid #t) + (sprite "images/creatures/penny/penny.sprite") + (x 3489) + (y 1280) + ) + (scriptedobject + (name "SIGN") + (layer -100) + (visible #f) + (physic-enabled #f) + (solid #f) + (sprite "images/tiles/signs/right.sprite") + (x 3200) + (y 1280) + ) (scripttrigger - (script "function shake_bush() -{ - //play_sound(\"sounds/rustle.wav\"); - local bushx = BUSH.get_pos_x(); - local bushy = BUSH.get_pos_y(); - for(local i = 0; i < 20; ++i) { - BUSH.set_pos(bushx + ( rand() % 6 ) - 3, bushy); - wait(0.05); - } -} - -if(!(\"script_ran\" in this)) { - script_ran <- true; - //initialize - Tux.deactivate(); - Tux.walk(0); - - //begin conversation and Tux rap - play_sound(\"speech/tux_hello.ogg\"); - wait(3.5); - play_sound(\"speech/penny_runt_01.ogg\"); - wait(1.5); - play_sound(\"speech/tux_murp_01.ogg\"); - wait(1.5); - RADIO.set_action(\"loud\"); - play_sound(\"speech/tux_rap.ogg\"); - wait(8); - shake_bush(); - wait(5); - shake_bush(); - wait(3); - shake_bush(); - wait(1.8); - - //enter Nolok - NOLOK.set_velocity(-220, 600); - NOLOK.set_visible(true); - Effect.fade_out(1.3); - wait(4); - - //darkness - NOLOK.set_visible(false); - NOLOK.set_solid(false); - PENNY.set_visible(false); - PENNY.set_solid(false); - RADIO.set_visible(false); - RADIO.set_solid(false); - - //wake up, Tux... - Effect.fade_in(3); - Tux.activate(); - Tux.kill(false); -}") + (script "trigger_state(\"rap_scene\");") (button #f) (width 32) (height 520) - (x 3392) + (x 3380) (y 832) ) (scripttrigger - (script "Effect.fade_out(2); - wait(2); - Level.finish(true);") + (script "trigger_state(\"end_level\"); +") + (button #f) (width 32) (height 380) - (x 4320) + (x 5760) (y 960) ) + (scripttrigger + (script "trigger_state(\"logo_in\"); +") + (button #f) + (width 32) + (height 540) + (x 1152) + (y 800) + ) + (scripttrigger + (script "trigger_state(\"intro_text\"); +") + (button #f) + (width 32) + (height 540) + (x 2528) + (y 800) + ) (particles-snow ) (spawnpoint @@ -183,8 +162,8 @@ if(!(\"script_ran\" in this)) { 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0 0 0 1325 1326 1327 1328 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 122 209 123 0 0 0 - 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 0 122 209 123 0 0 0 0 0 0 0 0 124 210 125 0 0 0 106 107 108 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 1278 1278 1278 1278 0 0 0 0 0 0 0 0 0 122 209 123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 107 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 1329 1330 1331 1332 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 - 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 24 0 25 0 0 0 1345 1346 1344 0 0 0 109 110 111 25 0 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 25 0 0 0 0 24 0 1345 1346 1344 0 0 0 0 1345 1346 1344 0 0 24 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 8 8 8 8 0 0 0 1278 1278 1278 1278 1278 1278 8 8 8 8 0 0 0 25 0 0 124 210 125 0 0 0 0 0 0 0 0 24 0 24 0 0 0 0 0 109 110 111 0 0 0 0 0 0 0 0 0 25 0 24 0 0 1345 1346 1344 0 0 0 0 0 0 0 25 0 0 8 1333 1334 1335 1336 0 25 0 0 0 0 0 0 0 0 0 0 0 8 8 8 0 1345 1346 1344 0 0 0 + 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 141 142 0 0 0 0 0 0 122 209 123 0 0 0 0 0 0 0 0 124 210 125 0 0 0 106 107 108 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 0 1278 1278 1278 1278 0 0 0 0 0 0 0 0 0 122 209 123 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 106 107 108 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 0 0 0 0 0 0 0 0 1329 1330 1331 1332 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 124 210 125 0 0 0 + 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 0 0 0 143 144 0 0 0 0 0 0 124 210 125 0 0 24 0 25 0 0 0 1345 1346 1344 0 0 0 109 110 111 25 0 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 25 0 0 0 0 24 0 1345 1346 1344 0 0 0 0 1345 1346 1344 0 0 24 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 8 8 8 8 0 0 0 1278 1278 1278 1278 1278 1278 8 8 8 8 0 0 0 25 0 0 124 210 125 0 0 0 0 0 0 0 0 24 0 24 0 0 0 0 0 109 110 111 0 0 0 0 0 0 0 0 0 25 0 24 0 0 1345 1346 1344 0 0 0 0 0 0 0 25 0 0 8 1333 1334 1335 1336 0 25 0 0 0 0 0 0 0 0 0 0 0 8 8 8 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1345 1346 1344 0 0 0 0 0 0 0 0 0 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 @@ Parser::Parser(bool translate) : dictionary_manager(0), dictionary(0), token(), - obst(), - searchpath() + searchpath(), + obst() { if(translate) { dictionary_manager = new tinygettext::DictionaryManager(); diff --git a/src/object/player.cpp b/src/object/player.cpp index c833a208b..2e2ea2840 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -345,9 +345,11 @@ Player::update(float elapsed_time) if(!dying && !deactivated) handle_input(); +/* // handle_input() calls apply_friction() when Tux is not walking, so we'll have to do this ourselves if (deactivated) apply_friction(); +*/ // extend/shrink tux collision rectangle so that we fall through/walk over 1 // tile holes @@ -1467,6 +1469,11 @@ void Player::walk(float speed) physic.set_velocity_x(speed); } +void Player::set_dir(bool right) +{ + dir = right ? RIGHT : LEFT; +} + void Player::set_ghost_mode(bool enable) { diff --git a/src/object/player.hpp b/src/object/player.hpp index 2e702d514..bcbbcbc79 100644 --- a/src/object/player.hpp +++ b/src/object/player.hpp @@ -248,6 +248,7 @@ private: void activate(); void deactivate(); void walk(float speed); + void set_dir(bool right); void do_jump_apex(); void early_jump_apex(); diff --git a/src/object/scripted_object.cpp b/src/object/scripted_object.cpp index e17de285a..68d13188a 100644 --- a/src/object/scripted_object.cpp +++ b/src/object/scripted_object.cpp @@ -78,8 +78,8 @@ ScriptedObject::move(float x, float y) void ScriptedObject::set_pos(float x, float y) { - printf("SetPos: %f %f\n", x, y); - bbox.set_pos(Vector(x, y)); + // printf("SetPos: %f %f\n", x, y); + MovingObject::set_pos(Vector(x, y)); physic.reset(); } diff --git a/src/scripting/player.hpp b/src/scripting/player.hpp index 80e04cefd..3551f50b8 100644 --- a/src/scripting/player.hpp +++ b/src/scripting/player.hpp @@ -57,6 +57,10 @@ public: */ virtual void walk(float speed) = 0; /** + * Face Tux in the proper direction + */ + virtual void set_dir(bool right) = 0; + /** * Set player visible or invisible */ virtual void set_visible(bool visible) = 0; @@ -84,6 +88,11 @@ public: virtual bool get_ghost_mode() = 0; /** + * start kick animation + */ + virtual void kick() = 0; + + /** * play cheer animation. * This might need some space and behave in an unpredictable way. Best to use this at level end. */ diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index 4dccd3264..c2bd91ee7 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -1266,6 +1266,35 @@ static SQInteger Player_walk_wrapper(HSQUIRRELVM vm) } +static SQInteger Player_set_dir_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0)) || !data) { + sq_throwerror(vm, _SC("'set_dir' 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->set_dir(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 'set_dir'")); + return SQ_ERROR; + } + +} + static SQInteger Player_set_visible_wrapper(HSQUIRRELVM vm) { SQUserPointer data; @@ -1403,6 +1432,30 @@ static SQInteger Player_get_ghost_mode_wrapper(HSQUIRRELVM vm) } +static SQInteger Player_kick_wrapper(HSQUIRRELVM vm) +{ + SQUserPointer data; + if(SQ_FAILED(sq_getinstanceup(vm, 1, &data, 0)) || !data) { + sq_throwerror(vm, _SC("'kick' called without instance")); + return SQ_ERROR; + } + scripting::Player* _this = reinterpret_cast (data); + + try { + _this->kick(); + + return 0; + + } catch(std::exception& e) { + sq_throwerror(vm, e.what()); + return SQ_ERROR; + } catch(...) { + sq_throwerror(vm, _SC("Unexpected exception while executing function 'kick'")); + return SQ_ERROR; + } + +} + static SQInteger Player_do_cheer_wrapper(HSQUIRRELVM vm) { SQUserPointer data; @@ -5034,6 +5087,13 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'walk'"); } + sq_pushstring(v, "set_dir", -1); + sq_newclosure(v, &Player_set_dir_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb"); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'set_dir'"); + } + sq_pushstring(v, "set_visible", -1); sq_newclosure(v, &Player_set_visible_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb"); @@ -5069,6 +5129,13 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'get_ghost_mode'"); } + sq_pushstring(v, "kick", -1); + sq_newclosure(v, &Player_kick_wrapper, 0); + sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t"); + if(SQ_FAILED(sq_createslot(v, -3))) { + throw SquirrelError(v, "Couldn't register function 'kick'"); + } + sq_pushstring(v, "do_cheer", -1); sq_newclosure(v, &Player_do_cheer_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t"); diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index d78330b61..fc945c24b 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -632,7 +632,7 @@ Main::run(int argc, char** argv) // So we simply mount that path here... std::string dir = FileSystem::dirname(g_config->start_level); std::string fileProtocol = "file://"; - int position = dir.find(fileProtocol); + size_t position = dir.find(fileProtocol); if(position != std::string::npos) { dir = dir.replace(position, fileProtocol.length(), ""); }