From: LMH Date: Thu, 11 Jul 2013 01:16:46 +0000 (-1000) Subject: Custom BonusBlocks now always run scripts if defined. The use of "script" as the... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e54fb8e8717ab803f27736bf0c5f8cef20537c6e;p=supertux.git Custom BonusBlocks now always run scripts if defined. The use of "script" as the contents can be used if the BonusBlock is only to run a script. --- diff --git a/src/object/bonus_block.cpp b/src/object/bonus_block.cpp index 4fa270400..6c136c355 100644 --- a/src/object/bonus_block.cpp +++ b/src/object/bonus_block.cpp @@ -88,7 +88,7 @@ BonusBlock::BonusBlock(const Reader& lisp) : sprite = sprite_manager->create(sprite_name); } else if(token == "count") { iter.value()->get(hit_counter); - } else if(token == "script") { + } else if(token == "script") { // use when bonusblock is to contain ONLY a script iter.value()->get(script); } else if(token == "contents") { std::string contentstring; @@ -258,13 +258,8 @@ BonusBlock::try_open(Player *player) } case CONTENT_SCRIPT: - { - if(script != "") { - std::istringstream stream(script); - Sector::current()->run_script(stream, "powerup-script"); - } - break; - } + { break; } // because scripts always run, this prevents default contents from being assumed + case CONTENT_LIGHT: { if(sprite->get_action() == "on") @@ -298,6 +293,11 @@ BonusBlock::try_open(Player *player) } } + if(script != "") { // scripts always run if defined + std::istringstream stream(script); + Sector::current()->run_script(stream, "powerup-script"); + } + start_bounce(player); if(hit_counter <= 0 || contents == CONTENT_LIGHT){ //use 0 to allow infinite hits }else if(hit_counter == 1){