From: LMH Date: Sat, 7 Sep 2013 07:26:47 +0000 (-1000) Subject: Secret areas can also trigger a script X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=170fca91703c93e50c4c30ce72867f7f27ef5ad0;p=supertux.git Secret areas can also trigger a script --- diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 1baeaef57..1bcfbc580 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -310,7 +310,7 @@ BonusBlock::try_open(Player *player) if(script != "") { // scripts always run if defined std::istringstream stream(script); - Sector::current()->run_script(stream, "powerup-script"); + Sector::current()->run_script(stream, "BonusBlockScript"); } start_bounce(player); diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 56e85a16e..8bddf8c69 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -45,6 +45,7 @@ SecretAreaTrigger::SecretAreaTrigger(const Reader& reader) : if(message == "") { message = _("You found a secret area!"); } + reader.get("script", script); message_displayed = false; } @@ -53,7 +54,8 @@ SecretAreaTrigger::SecretAreaTrigger(const Rectf& area, std::string fade_tilemap message_timer(), message_displayed(), message(_("You found a secret area!")), - fade_tilemap(fade_tilemap) + fade_tilemap(fade_tilemap), + script() { bbox = area; message_displayed = false; @@ -98,6 +100,10 @@ SecretAreaTrigger::event(Player& , EventType type) } } + if(script != "") { + std::istringstream stream(script); + Sector::current()->run_script(stream, "SecretAreaScript"); + } } } } diff --git a/src/trigger/secretarea_trigger.hpp b/src/trigger/secretarea_trigger.hpp index 2b0e10579..9f1e441b3 100644 --- a/src/trigger/secretarea_trigger.hpp +++ b/src/trigger/secretarea_trigger.hpp @@ -42,6 +42,7 @@ private: bool message_displayed; std::string message; /**< message to display, default "You found a secret area!" */ std::string fade_tilemap; /**< tilemap to fade away when trigger is activated, or empty if you don't care */ + std::string script; /**< optional script to run when trigger is activated */ }; #endif