From e54fb8e8717ab803f27736bf0c5f8cef20537c6e Mon Sep 17 00:00:00 2001 From: LMH Date: Wed, 10 Jul 2013 15:16:46 -1000 Subject: [PATCH] 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. --- src/object/bonus_block.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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){ -- 2.11.0