Update INSTALL to tell users to do CMAKE_BUILD_TYPE=DEBUG rather that DEBUG=ON
[supertux.git] / src / scripting / functions.cpp
index ecc2bf9..95d8607 100644 (file)
@@ -51,6 +51,8 @@
 #include "squirrel_util.hpp"
 #include "time_scheduler.hpp"
 
+extern float game_speed;
+
 namespace Scripting
 {
 
@@ -96,6 +98,11 @@ void shrink_screen(float dest_x, float dest_y, float seconds)
   main_loop->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds));
 }
 
+void abort_screenfade()
+{
+  main_loop->set_screen_fade(NULL);
+}
+
 std::string translate(const std::string& text)
 {
   return dictionary_manager.get_dictionary().translate(text);
@@ -163,14 +170,23 @@ void save_state()
 {
   using namespace WorldMapNS;
 
-  if(World::current() == NULL)
+  if(World::current() == NULL || WorldMap::current() == NULL)
     throw std::runtime_error("Can't save state without active World");
 
-  if(WorldMap::current() != NULL)
-    WorldMap::current()->save_state();
+  WorldMap::current()->save_state();
   World::current()->save_state();
 }
 
+void update_worldmap()
+{
+  using namespace WorldMapNS;
+
+  if(WorldMap::current() == NULL)
+    throw std::runtime_error("Can't update Worldmap: none active");
+
+  WorldMap::current()->load_state();
+}
+
 // not added to header, function to only be used by others
 // in this file
 bool validate_sector_player()
@@ -178,13 +194,13 @@ bool validate_sector_player()
   if (Sector::current() == 0)
   {
     log_info << "No current sector." << std::endl;
-       return false;
+    return false;
   }
 
   if (Sector::current()->player == 0)
   {
     log_info << "No player." << std::endl;
-       return false;
+    return false;
   }
   return true;
 }
@@ -203,7 +219,7 @@ void grease()
 {
   if (!validate_sector_player()) return;
   ::Player* tux = Sector::current()->player; // Scripting::Player != ::Player
-  tux->physic.vx = tux->physic.vx*3;
+  tux->physic.set_velocity_x(tux->physic.get_velocity_x()*3);
 }
 
 void invincible()
@@ -261,6 +277,10 @@ void camera()
   log_info << "Camera is at " << Sector::current()->camera->get_translation().x << "," << Sector::current()->camera->get_translation().y << std::endl;
 }
 
+void set_gamma(float gamma) {
+  SDL_SetGamma(gamma, gamma, gamma);
+}
+
 void quit()
 {
   main_loop->quit();
@@ -271,4 +291,9 @@ int rand()
   return systemRandom.rand();
 }
 
+void set_game_speed(float speed)
+{
+  ::game_speed = speed;
+}
+
 }