This wiki has been moved to into the mediawiki branch.


From SuperTux
Revision as of 00:26, 26 January 2010 by Octo (Talk | contribs)

Jump to: navigation, search


The Level class provides basic controlling functions for the current level.


An instance named Level is available from scripts and the console. (Note: class and eponymous instance might create potential conflicts – the name of one might be changed eventually)


finish(bool win) Ends the current level. If you set win to true, the level is marked as completed if launched from a worldmap.
Tip: Very useful if you have created a frustrating level and want to, at some point, save the player from agony.
spawn(string sectorname, string spawnpointname) Respawns Tux in the sector sectorname at the spawnpointname spawnpoint.
Exceptions: If sectorname or spawnpointname are empty or the specified sector does not exist, the function will bail out first chance it gets. If the specified spawnpoint doesn't exist, Tux will be spawned at the spawnpoint named main. If this spawnpoint doesn't exist either, Tux will simply end up at the origin (top-left 0, 0).
flip_vertically() Flips the level vertically (i.e. top is now bottom and vice versa). Call again to revert the effect.
Tip: Make sure the player can land on something after the level is flipped!
toggle_pause() Toggle pause
edit(bool editing) Change to/from edit mode



Example code


The following code teleports the player to spawnpoint "main" in sector "underground".

  (script "Level.spawn(\"underground\", \"main\");]]")
  (button #f)
Scripting reference
Ambient sound · Camera · Candle · Display effect · Floating image · Globals · Level · Level time · Path · Platform · Player · Scripted object · Sector · Sound · Text · Thunderstorm · Tilemap · Will-o-wisp · Wind