Custom BonusBlocks now always run scripts if defined. The use of "script" as the...
authorLMH <lmh.0013@gmail.com>
Thu, 11 Jul 2013 01:16:46 +0000 (15:16 -1000)
committerLMH <lmh.0013@gmail.com>
Thu, 11 Jul 2013 01:17:13 +0000 (15:17 -1000)
src/object/bonus_block.cpp

index 4fa2704..6c136c3 100644 (file)
@@ -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){